conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("databas.mdb")
Vilka förändringar behöver jag göra för att öppna databasen DSN-lös i detta:
<%
' Declaring variables
Dim email, con, data_source, sql_insert, sql_check, rs
email = Request.Form("email")
' Check that email address is empty or not. If email address
' is not empty then continue, otherwise redirect the user back to
' the main page
If Len(email) Then
' Note you can add your database's DSN here if you want
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("mail.mdb")
' Our SQL statements
sql_check = "select email from users where email = '" & email & "'"
sql_insert = "insert into users( email ) values ('" & email & "')"
' Lets first check to see if the email address is alread present in
' the database. Create the instance of Connection Object and then
' open the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
Set rs = con.Execute (sql_check, , 1)
' If email address is not present then add it to the database
If rs.EOF Then
con.Execute sql_insert
' Displaying the result of successful entry to the user
Response.Write "Thank you. Your email address <b>" & email & _
"</b> was successfully entered into the database"
' But if email address is already present then display it to
' the user
Else
Response.Write "Your email address " & email & _
" is already present in the database. Thank you."
End If
' Done. Disconnecting and setting Connection Object to Nothing
con.Close
Set con = Nothing
' And if the email address submitted was empty Then
Else
Response.Redirect "default.asp"
End If
%>
Jag vill alltså öppna och använda databasen utan en DSN-koppling.
Tacksam för svar...
------------------
/Sammy Swärd