Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can i get autonumber id with access?
Message
Information générale
Forum:
Visual Basic
Catégorie:
Access
Divers
Thread ID:
00506327
Message ID:
00507851
Vues:
21
i have a function in a module that returns my recordset. this is how i'm gettin a connection. all i do is pass a string that contains the SQL. the code is below.

Public Function GetRecordSet(ByVal strQuery As String) As ADODB.Recordset
Dim oConn As New ADODB.Connection
Dim rsObj As ADODB.Recordset
Dim strConnection As String
Dim strSearch As String

Set rsObj = New ADODB.Recordset

rsObj.CursorLocation = adUseClient

strConnection = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=dev; password=dev"

oConn.Open strConnection
rsObj.ActiveConnection = oConn
rsObj.Open strQuery, , adOpenDynamic, adLockPessimistic

If rsObj.EOF = False Then
rsObj.MoveFirst
End If

' put recordset in property
oRecSet = rsObj
Set GetRecordSet = rsObj
End Function

from the ado2.6 reference book, it looks like i can get the generated id using odbc connection if i have cursorlocation = server, cursor type = keyset, lock type = pessimistic/optimistic (of course, i don't know what the last two attributes are). anyway, i thought i needed to have the cursorlocation = adUseServer but that didn't work and the datagrid wasn't working until i changed the cursorlocation = adUseClient (thanks again). so i can create different function for these two scenarios but i can't seem to get the generated id to work so at this point it doesn't make sense to write another function until i get it working.

piper
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform