The initial leadership assignment is to use VB to connect the database, and later because I do not understand VB, and use JS
Vb,js is a client language and can only be run locally. Can no longer run on server
The reason is that the local connection database address can use a relative or absolute path, and the location of the database is not able to get the server file address locally!
I look at the major forums online and paste, find the Server object method MapPath can get the file path
The error message server object is not defined by the Small series test server to get the path. After changing to ASP code, run normally!
Get database connection
<%
Set conn = Server.CreateObject ("ADODB. Connection ")//Get service Driver
Conn. Open "Driver={microsoft Access Driver (*.mdb)};d bq=" &server.mappath ("#abc. mdb")//Set connection database to access driver, specify database file
Set Rs=server.createobject ("Adodb.recordset")//Create service return object
%>
Add data
<%
User=request.form ("Po.loginname")
Pwd=request.form ("password")
Sql= "SELECT * from [user] where user= '" +user+ "' and pwd = '" +pwd+ "'"
Rs.Open sql,conn,1,1
%>
Update data
<%
User=request.form ("User")
Pwd=request.form ("pwd")
Sql= "SELECT * from [user] where user= '" +user+ ""
Rs.Open sql,conn,1,3
If Rs.recordcount>0 Then
Response.Write ("<script>alert (' user already registered, please login!") '); javascript:window.location.href= ' Login.asp ' </script> ")
Response. End ()
End If
Rs.addnew
RS ("user") =user
RS ("pwd") =pwd
Rs.update
Response.Write ("<script>alert" (' Registered success!); javascript:window.location.href= ' login.asp ' </script> ')
Response. End ()
Rs.close
Conn.close
%>
ASP Operations Database Access