Versions des environnements
Network:
Windows 2003 Server
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
>
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement