Imports ADODB
Const adOpenStatic = 3
Const adLockOptimistic = 3
Dim objConn As ADODB.Connection
Dim objRS
Dim strDBName, strTable As String
strDBName = "MyLibrary.mdb"
strTable = "Books"
objConn = CreateObject("ADODB.Connection")
objRS = CreateObject("ADODB.Recordset")
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strDBName)
objRS.Open("SELECT * FROM " & strTable,
objConn, adOpenStatic, adLockOptimistic)
objRS.AddNew()
objRS("Book") = tbBook.Text
objRS("Author") = tbAuthor.Text
objRS.Update()
objRS.Close()
objConn.Close()
objRS = Nothing
objConn = Nothing
MsgBox("Data Added Successfully")
Book and Author names are read from the GUI. Note that connection and recordset are closed before setting to Nothing
Getting confused first ADOX and then ADODB...Let me add more to confusion by adding more terms like ADO, ADO.NET, DAO, RDO, OLEDB, ODBC...
To sort out this confusion, read post on Microsoft Data Access Components at blog on Computer Science Notes.
0 Comments