C
CES
This is the first time I've tried to convert my .asp ado connection to the
..NET framework and I'm totally lost. Most of the examples I've seen are
incompliant or more complicated then I can comprehend. I was wondering If
someone could point me to a referance that showes an entire example of
connecting to a database and adding a record to a table within the database.
I'm pretty sure that the connection string below is correct:
Dim dbPath As String = "c:\database.mdb"
Dim cnString as String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
& dbPath
Dim cnObj as OleDbConnection = New OleDbConnection(cnString)
cnObj.Open()
Dim sql AS String = "SELECT * FROM Visitors"
Dim objCom as OleDbCommand = New OleDbCommand(sql, cnObj)
But here is where I get lost I'm not sure if I need to open a
OleDbDataReader in order to add a record to the database or what. The code
I'm trying to replicate is as follows:
dbPath = "c:\database.mdb"
Set cnLog = Server.CreateObject("ADODB.Connection")
cnStLog = "driver={Microsoft Access Driver (*.mdb)};" & '"dbq=" & dbPath
cnLog.Open cnStLog,"",""
Set rsLog = Server.CreateObject("ADODB.Recordset")
sql = "Select * From Visitors"
rsLog.Open sql, cnLog, 2, 3
rsLog.AddNew
rsLog("X") = "New Data"
rslog.Update
rsLog.Close
Set rsLog = Nothing
cnLog.Close
Set cnLog = Nothing
Thanks for any help.
CES
..NET framework and I'm totally lost. Most of the examples I've seen are
incompliant or more complicated then I can comprehend. I was wondering If
someone could point me to a referance that showes an entire example of
connecting to a database and adding a record to a table within the database.
I'm pretty sure that the connection string below is correct:
Dim dbPath As String = "c:\database.mdb"
Dim cnString as String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
& dbPath
Dim cnObj as OleDbConnection = New OleDbConnection(cnString)
cnObj.Open()
Dim sql AS String = "SELECT * FROM Visitors"
Dim objCom as OleDbCommand = New OleDbCommand(sql, cnObj)
But here is where I get lost I'm not sure if I need to open a
OleDbDataReader in order to add a record to the database or what. The code
I'm trying to replicate is as follows:
dbPath = "c:\database.mdb"
Set cnLog = Server.CreateObject("ADODB.Connection")
cnStLog = "driver={Microsoft Access Driver (*.mdb)};" & '"dbq=" & dbPath
cnLog.Open cnStLog,"",""
Set rsLog = Server.CreateObject("ADODB.Recordset")
sql = "Select * From Visitors"
rsLog.Open sql, cnLog, 2, 3
rsLog.AddNew
rsLog("X") = "New Data"
rslog.Update
rsLog.Close
Set rsLog = Nothing
cnLog.Close
Set cnLog = Nothing
Thanks for any help.
CES