tmkan
02-06-2004, 07:04 AM
Background: Win XP, VB.Net, connect to Access XP file by Oledb
Problem: I have an Access file with a table ccb. There is an autonumbered field "key" in it. My VB program creates some rows and later accesses the "key" field. The problem is that VB still sees the "key" field as DBNull. After I quited my program and looked at the Access file, all the "key"s are there. The other fields are fine.
My codes are roughly like:
connCCB = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=c:\data\db1.mdb;Mode=ReadWrite|Share Deny None")
connCCB.Open()
adptrCCB3 = New OleDbDataAdapter("select ccb.* from ccb order by key", connCCB)
autogen = New OleDbCommandBuilder(adptrCCB3)
dsCCB = New DataSet()
adptrCCB3.Fill(dsCCB, "ccb")
dtCCB3 = dsCCB.Tables("ccb")
drCCB = dtCCB3.NewRow
dtCCB3.Rows.Add(drCCB)
adptrCCB3.Update(dsCCB, "ccb")
adptrCCB3.Fill(dsCCB, "ccb")
For i = 0 To dtCCB3.Rows.Count - 1
drCCB = dtCCB3.Rows(i)
lngFrom = drCCB("key") *** Error here! "key" is still DBNull
Next
What is the thing that I missed? Thanks a lot!!!!
Problem: I have an Access file with a table ccb. There is an autonumbered field "key" in it. My VB program creates some rows and later accesses the "key" field. The problem is that VB still sees the "key" field as DBNull. After I quited my program and looked at the Access file, all the "key"s are there. The other fields are fine.
My codes are roughly like:
connCCB = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=c:\data\db1.mdb;Mode=ReadWrite|Share Deny None")
connCCB.Open()
adptrCCB3 = New OleDbDataAdapter("select ccb.* from ccb order by key", connCCB)
autogen = New OleDbCommandBuilder(adptrCCB3)
dsCCB = New DataSet()
adptrCCB3.Fill(dsCCB, "ccb")
dtCCB3 = dsCCB.Tables("ccb")
drCCB = dtCCB3.NewRow
dtCCB3.Rows.Add(drCCB)
adptrCCB3.Update(dsCCB, "ccb")
adptrCCB3.Fill(dsCCB, "ccb")
For i = 0 To dtCCB3.Rows.Count - 1
drCCB = dtCCB3.Rows(i)
lngFrom = drCCB("key") *** Error here! "key" is still DBNull
Next
What is the thing that I missed? Thanks a lot!!!!