Information générale
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Thanks for your help. I was using SQL server on the network. The following is my code to access the SQL server for the data and then display the data in the data grid. After the user make any changes and click "update", the data will be saved in the SQL server. Do you see any problems in the code?
Dim db As Connection
Dim WithEvents rsgrid As ADODB.Recordset
Private Sub RSetInit(sSQL As String, db As Connection, rs As Recordset)
'Get the record set
db.Open "dsn=csudb"
rs.CursorLocation = adUseClient
rs.Open sSQL, db, adOpenStatic, adLockOptimistic
Private Sub txtFamGet(sID As String)
'Get a record for a given ID.
Dim sSQL As String
sSQL = "SELECT f.idnum, f.fidnum, i.fulname, f.related FROM donFam f, CSUid i WHERE f.idnum = '" & sID & "' And i.idnum = f.fidnum"
Set db = New ADODB.Connection
Set rsgrid = New ADODB.Recordset
RSetInit sSQL, db, rsgrid
Set grdFam.DataSource = rsgrid
'Make some changes
'Save changes
If mbEditFlag Or mbAddNewFlag Then
rsgrid.UpdateBatch adAffectAll
End If
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