DataSet back to DBF file?

  • Thread starter Thread starter Patrick Dugan
  • Start date Start date
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
 
Patrick,
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

Don't you need a WHERE clause in the UPDATE command?

Mike
 
Patrick Dugan said:
Is there an example somewhere that shows how to populate a DBF file from a
DataSet?

=> microsoft.public.dotnet.framework.adonet.
 
Hefried,

This is foxpro, you will see that Cindy Wingarden will probably answer this
question here as well.

In my opinion it is not needed to create a multipost.

Cor
 
Cor Ligthert said:
This is foxpro, you will see that Cindy Wingarden will probably answer
this question here as well.

Mhm... With the same excuse my colleagues from university could post here
instead of mailing me because I'll see the question here...

SCNR
 
Mhm... With the same excuse my colleagues from university could post here
instead of mailing me because I'll see the question here...
I think that is not a good idea from you asking that to do.

Cor
 
Back
Top