SparowHawk
August 1st, 1999, 01:29 PM
I'm having a rather strange reaction to the following code using VB6. It is an mdb database with the table in question having two fields (It's also empty at present)
SectionID autonumbered (Primary)
Section Text field
Code:
public conn as new ADODB.Connection
public rsSection as new ADODB.Recordset
set conn = new ADODB.Connection
set rsSection = new ADODB.Recordset
With conn
.Provider = "Microsoft.jet.oledb.3.51"
.Open App.Path & "\My.mdb"
End With
rsSection.Open "SELECT * FROM SECTION", conn, adOpenStatic, adLockBatchOptimistic
rsSection.AddNew
rsSection!SECTION = me.txtTextBox.Text
rsSection.Update
rsSection.Close
conn.Close
I have Microsoft ActiveX Data Objects 2.0 Library added to the references.
After running the code and look at the table using Access97, I find it appears blank. However, if I manually insert a letter in the Section (Text) field the autonumber will read 2 instead of the 1 which I would expect. Continually running this code will only add to the autonumbered field but leave the text field blank. Can anyone shed some light on this for me? I'm expreienced in DAO but new to ADO and obviously missing something here ... Could I be opening the database incorrectly?
Thank you!
SectionID autonumbered (Primary)
Section Text field
Code:
public conn as new ADODB.Connection
public rsSection as new ADODB.Recordset
set conn = new ADODB.Connection
set rsSection = new ADODB.Recordset
With conn
.Provider = "Microsoft.jet.oledb.3.51"
.Open App.Path & "\My.mdb"
End With
rsSection.Open "SELECT * FROM SECTION", conn, adOpenStatic, adLockBatchOptimistic
rsSection.AddNew
rsSection!SECTION = me.txtTextBox.Text
rsSection.Update
rsSection.Close
conn.Close
I have Microsoft ActiveX Data Objects 2.0 Library added to the references.
After running the code and look at the table using Access97, I find it appears blank. However, if I manually insert a letter in the Section (Text) field the autonumber will read 2 instead of the 1 which I would expect. Continually running this code will only add to the autonumbered field but leave the text field blank. Can anyone shed some light on this for me? I'm expreienced in DAO but new to ADO and obviously missing something here ... Could I be opening the database incorrectly?
Thank you!