P
Patrick Dugan
Is there an example somewhere that shows how to populate a DBF file from a
DataSet?
I can read in the DBF file into a DataAdapter and then populate a DataSet,
then fill a dbGrid for display. If the user modifies the
dbGrid, I want to save those changes back to the DBF where this all came
from. How do you save back to the DBF?
Here is the code I have so far:
sSqlStr = "SELECT * FROM BLOCK"
strConnect = "Provider=VFPOLEDB.1;Data Source=" & _UploadsDir & "\Block.dbf"
& ";Mode=Share Deny None;Extended Properties="""";User ID="""";Mask
Password=False;Cache Authentication=False;Encrypt Password=False;Collating
Sequence=MACHINE;DSN="
Dim OleDBConn As New OleDb.OleDbConnection(strConnect)
MyDBCommand.Connection = OleDBConn
MyDBCommand.CommandText = sSqlStr
MyDAdb.SelectCommand = MyDBCommand
MyDAdb.Fill(MyDS, "Block")
' Here is where I populate the dbgrid...
' This works correctly and displays the data...
DataGrid1.DataSource = MyDS.Tables(0)
.....................
.....................
.....................
' This is where I need to write the data back out to the dbf file
' This doesnt seem to work but doesnt throw an error either...
MyDAdb.UpdateCommand = New Data.OleDb.OleDbCommand(Nothing, OleDBConn)
With MyDAdb.UpdateCommand
..CommandText = "Update BLOCK SET name = @name"
..Parameters.Add(New Data.OleDb.OleDbParameter("@name",
Data.OleDb.OleDbType.Char, 20, "name"))
End With
DataSet?
I can read in the DBF file into a DataAdapter and then populate a DataSet,
then fill a dbGrid for display. If the user modifies the
dbGrid, I want to save those changes back to the DBF where this all came
from. How do you save back to the DBF?
Here is the code I have so far:
sSqlStr = "SELECT * FROM BLOCK"
strConnect = "Provider=VFPOLEDB.1;Data Source=" & _UploadsDir & "\Block.dbf"
& ";Mode=Share Deny None;Extended Properties="""";User ID="""";Mask
Password=False;Cache Authentication=False;Encrypt Password=False;Collating
Sequence=MACHINE;DSN="
Dim OleDBConn As New OleDb.OleDbConnection(strConnect)
MyDBCommand.Connection = OleDBConn
MyDBCommand.CommandText = sSqlStr
MyDAdb.SelectCommand = MyDBCommand
MyDAdb.Fill(MyDS, "Block")
' Here is where I populate the dbgrid...
' This works correctly and displays the data...
DataGrid1.DataSource = MyDS.Tables(0)
.....................
.....................
.....................
' This is where I need to write the data back out to the dbf file
' This doesnt seem to work but doesnt throw an error either...
MyDAdb.UpdateCommand = New Data.OleDb.OleDbCommand(Nothing, OleDBConn)
With MyDAdb.UpdateCommand
..CommandText = "Update BLOCK SET name = @name"
..Parameters.Add(New Data.OleDb.OleDbParameter("@name",
Data.OleDb.OleDbType.Char, 20, "name"))
End With