|
You are in full control when using standard ADO and protected file areas. No need to request a ODBC and wait. Just upload your access database - and you're off and running.
The following code is an example of the most basic database operations:
dim cnn
dim mydatabase
'Create a connection object.
Set cnn = Server.CreateObject("ADODB.Connection")
' Use my function "getprovider" to get path to your database
mydatabase=getprovider("comments.mdb")
' Open the database
cnn.Open (mydatabase)
Response.Write("OK")
' Open the table
dim Mytable
set mytable = Server.CreateObject("ADODB.RecordSet")
mytable.open "SELECT * FROM contact", cnn ,adOpenKeyset,3
mytable.movefirst
While not Mytable.EOF
if mytable("FirstName")="(user input)" then
Response.Write(" ")
response.Write(mytable("FirstName"))
Response.Write(" ")
response.Write(mytable("LastName"))
end if
Mytable.movenext
wend
' A dbstore is nothing more than adding data like this..
' Add a record
Mytable.AddNew
' Specify contents of fields... OBEY Database settings!!!
Mytable("FirstName")="(other user input)"
Mytable("LastName")="Testing"
' Update the database
Mytable.Update
' Ok, we're done with this example. Close table and database.
mytable.close
cnn.close
... other processing
Here is the "GetProvider" function used above. You are free to code this however you want. It is just here for example.
Function GetProvider(database)
dim myprovider
dim providerstring
myprovider = "Provider=Microsoft.Jet.OLEDB.4.0;"
providerstring = myprovider + "Data Source=" +Request.ServerVariables.Item("APPL_PHYSICAL_PATH") + "_root\"+database
GetProvider="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+providerstring
End function
|