Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Access Method
Message
 
To
31/10/2007 13:46:46
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
VB 8.0
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01265411
Message ID:
01265779
Views:
13
So I used the DataSet as you suggested and was able to populate it and bind it to controls on the form. Now, I want to save changes. I have the following code but is not working because no primary key is defined in the source table. How do I specify a Primary key in the DataAdapter/CommandBuilder?


Public Function SaveCust(ByVal ds As DataSet, ByVal cTable As String) As Boolean

Dim conn As OleDb.OleDbConnection = GetConnection()
Dim sql As String = "select * from " + cTable
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, conn)
Dim cb As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds, "Cust")
ds.AcceptChanges()
End If
da.Dispose()
conn.Close()
conn.Dispose()

Return True

End Function


>Patrick,
>
>Do NOT put the DataAccess in the Form. You need to organize your solution so that you have separate projects for DataAccess (and separate Business projects too). Then, have the DataAccess class get your data from the database and pass back a DataSet with the DataTable in it. Use that to bind to your controls. Since you say the layout is the same for all your tables, simply create a DataSet based on an .xsd of your table's layout.
>
>If you need more direction than this, just ask a few questions and we'll see if we can get you pointed in the right direction.
>
>~~Bonnie
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform