Microsoft Visual Basic ADO
Opening A Connection Private Sub Form_Load() dim db as connection set db = new connection db.open "PROVIDER=microsoft.jet.oledb.3.51;_ DataSource=c:\vbbb\adocode\db.mdb;" .... ... Binding controls to Record Set ..... ... set text1.datasource = adorecordset text1.datafield = "name" Updating a Record in a Record Set adorecordset2.update Refreshing the Record Set Private Sub cmdRefresh_click() on Error Goto ErrLabel adorecordset2.requery exit sub ErrLabel: MsgBox Err.description End sub Add a Record to a Record Set adorecordset2.addnew SQL adorecordset2.open "select * from student", db, adoopenstatic, adolockoptimistic | Creating a Record Set recordset.open[source,[activeconnection,[type,[locktype,[option]]]] where Type is either dbopenkeyset(odbc), dbopendynamic, dbopenstatic dim adorecordset as recordset Private Sub Form_Load() dim db as connection set db = new connection db.open "PROVIDER=microsoft.jet.oledb.3.51;_ DataSource=c:\vbbb\adocode\db.mdb;" set adorecordset = new recordset adorecordset.open "select * from student", db, adoopenstatic,_ adolockoptimistic ..... ... Move a record Private Sub cmdNext.click() on Error Goto ErrLabel if not adorecordset.eof then adorecordset.movenext End If if adorecordset.eof and adorecordset.recordcount > 0 then adorecordset.movelast End If exit sub ErrLabel: MsgBox Err.description ENd Sub |

