Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/01/2011, 09:26
deivis2011
 
Fecha de Ingreso: enero-2011
Mensajes: 22
Antigüedad: 13 años, 3 meses
Puntos: 0
Respuesta: como guardo o transformo a dbf en visual studio

gracias por la respuesta pero ya lobre pasar los datos desde un datatable a un archivo dbf, es mas ahi te paso codigo =)

Dim table As DataTable = loadQuery()
table.Columns.Add("1", GetType(String))
table.Columns.Add("2", GetType(String))
table.Columns.Add("3", GetType(String))

If table.Rows.Count > 0 Then
Response.Write("<script>alert('lleno'); </script>")

For f As Integer = 0 To table.Rows.Count - 1
table.Rows.Add(table.Rows(f).Item("id_lote").ToStr ing, table.Rows(f).Item("OBJECTID").ToString, table.Rows(f).Item("tip_uso").ToString)

'Response.Write(table.Rows(f).Item("id_lote").ToSt ring)
Next
Else
Response.Write("<script>alert('vacio'); </script>")
End If

' Dim dt As DataTable = New OleDb.OleDbDataAdapter(sSQL, con)

''DataTable of rows to send to .dbf fi
''Since we want the DataAdapter to treat these rows as pending inserts
'' the RowState of all such rows needs to be marked as Added.
'' If yours aren't, then call the SetAdded method on each DataRow.
'Dim table As New DataTable()



''Using a ConnectionStringBuilder to create the connection string
Dim builder As New OleDb.OleDbConnectionStringBuilder()
builder.Provider = "VFPOLEDB"
builder.DataSource = "c:\sset5\"

'Connect
Dim connection As New OleDb.OleDbConnection(builder.ConnectionString)
connection.Open()

'Clear or create the table as necessary
Dim command As OleDb.OleDbCommand = connection.CreateCommand()
If System.IO.File.Exists("c:\sset5\te1.dbf") Then
'if (System.IO.File.Exists(directory + @"\te1.dbf"))
command.CommandText = "DELETE FROM te1"
Else
command.CommandText = "CREATE TABLE te1 (id_lote c(50), OBJECTID c(5),tip_uso c(10))"
'command.CommandText = "CREATE TABLE te1 (n_uni_cat c(6), n_paquete c(5)) "
End If
command.ExecuteNonQuery()

'Create the DataAdapter
command.CommandText = "SELECT id_lote, OBJECTID, tip_uso FROM te1"
Dim adapter As New OleDbDataAdapter(command)

'Create the insert logic
Dim insertCommand As OleDb.OleDbCommand = connection.CreateCommand()
adapter.InsertCommand = insertCommand
insertCommand.CommandText = "INSERT INTO te1 (id_lote, OBJECTID,tip_uso) VALUES (?, ?,?)"
insertCommand.Parameters.Add("id_lote", OleDbType.Char, 50, "id_lote")
insertCommand.Parameters.Add("OBJECTID", OleDbType.Char, 5, "OBJECTID")
insertCommand.Parameters.Add("tip_uso", OleDbType.Char, 10, "tip_uso")
insertCommand.UpdatedRowSource = UpdateRowSource.None

'Or use a CommandBuilder
'OleDbCommandBuilder commandBuilder =
' new OleDbCommandBuilder(adapter);

'Submit the pending updates
adapter.Update(table)


--- ahora mi problema es que como puedo obterner los campos de un gridview para realizar mi consulta en mi query, ojala puedas ayudarme gracias =)