ASP DataBase conection
I have set up my computer to run server side scripts but am unable to communicate with my access database. I have wrote the code for the ODBC connection but can never write to , update, or view database data.
Will eventually change the database to SQL or oracle but wish to use access to start with for testing the ASP code as have no experience with SQL or Oracle databases.
Im using Windows 2000 and office 2000. My server side scripts run ok, so not sure what im doing wrong.
Will eventually change the database to SQL or oracle but wish to use access to start with for testing the ASP code as have no experience with SQL or Oracle databases.
Im using Windows 2000 and office 2000. My server side scripts run ok, so not sure what im doing wrong.
well, give us a clue as to the problem. "Not working" is rather a large area to cover.
I'm guessing you've created a database connection..
dim objdbConn
set objDBConn=Server.CreateObject("ADODB.Connection")
objDBConn.open "DSN=xxxxxxx;"
Then a recordset...
dim objrs
set objrs=Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = objDBConn
rs.open "select * from wherever..."
And that should work providing your ODBC is working properly.
I'm guessing you've created a database connection..
dim objdbConn
set objDBConn=Server.CreateObject("ADODB.Connection")
objDBConn.open "DSN=xxxxxxx;"
Then a recordset...
dim objrs
set objrs=Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = objDBConn
rs.open "select * from wherever..."
And that should work providing your ODBC is working properly.
.....or use a connection string:
' define variables
dim strCon
dim objDBConnect
dim objRS
dim strSQL
' define connection string
strCon = "Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=c:\database.mdb"
' define object types
set objDBConnect = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.Recordset")
' open database connection
objDBConnect.Open strCon
' define your sql query
strSQL = "SELECT * FROM tblTableName"
' open recordset
objRS.Open strSQL, objDBConnect, adOpenForwardOnly, adLockReadOnly, adcmdtext
' do your recordset processing here
objRS.Close
' and dont forget to tidy up!!
objDBConnect.close
set objRS = nothing
set objDBConnect = nothing
cool stuff on db locktypes
' define variables
dim strCon
dim objDBConnect
dim objRS
dim strSQL
' define connection string
strCon = "Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=c:\database.mdb"
' define object types
set objDBConnect = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.Recordset")
' open database connection
objDBConnect.Open strCon
' define your sql query
strSQL = "SELECT * FROM tblTableName"
' open recordset
objRS.Open strSQL, objDBConnect, adOpenForwardOnly, adLockReadOnly, adcmdtext
' do your recordset processing here
objRS.Close
' and dont forget to tidy up!!
objDBConnect.close
set objRS = nothing
set objDBConnect = nothing
cool stuff on db locktypes
Thread
Thread Starter
Forum
Replies
Last Post



