非常感谢你的帮助,我用的方法是如下
Sub LoginBtn_Click(Sender As Object, E As EventArgs)
dim strcnn as string
dim strsql as string
dim objdataset as new dataset
dim objcnn as new oledbconnection
dim objadapter as new oledbdataadapter
' set the connection and query details
strcnn="provider=microsoft.jet.oledb.4.0;" & _
"data source=mydriver:\mydata.mdb"
strsql="SELECT tbla.Aid, tbla.Aname FROM tbla "& _
"WHERE (((tbla.Aname)='" & user.identity.name & "'))"
'open the connection and set the command
objcnn=new oledbconnection(strcnn)
objadapter=new oledbdataadapter(strsql,objcnn)
'fill the dataset with the data
objadapter.fill(objdataset,"tbla")
'add new row to the table
dim objtable as datatable
dim objnewrow as datarow
'generate the update commands
dim objbuilder as oledbcommandbuilder
objbuilder=new oledbcommandbuilder(objadapter)
objadapter.updatecommand=objbuilder.getupdatecommand()
objadapter.insertcommand=objbuilder.getinsertcommand()
objadapter.deletecommand=objbuilder.getdeletecommand()
'update the data store
objadapter1.update(objdataset,"tbla")
'get the aid
strsql="SELECT tbla.Aid, tbla.Aname FROM tblaccount "& _
"WHERE (((tbla.Aname)='" & user.identity.name & "'))"
dim objcmd as new oledbcommand(strsql,objcnn)
dim objdatareader as oledbdatareader
dim aIDnmb as string