| | |
asp connecting to database
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2005
Posts: 4
Reputation:
Solved Threads: 0
Alright guys, I'm having quite a time with this one. I'm getting an VB script error : Microsoft VBScript compilation error '800a0408'
Invalid character
/addcust2database.asp, line 25
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;" & _ "dsn=www.motorlists.com;" &_ "uid=mechanic; pwd=k1n3t1c;" &_ "Server.MapPath("motorlists.mdb");"
I'll print the code, but it's pretty long. The purpose is to send a form to database. I was able to rid it once by removing the quotations from motorlists.mdb but then it wouldn't run at all. well here you go:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'variables
Dim fname, lname, Email, CEmail, Address, City, State
Dim MM_conn1_STRING, connection, sSQL
'values from Form, values entered to variables
fname = Request.Form("fname")
lname = Request.Form("lname")
Email = Request.Form("Email")
CEmail = Request.Form("CEmail")
Address = Request.Form("Address")
City = Request.Form("City")
State = Request.Form("State")
'SQL statements and Query
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('fname', 'lname', 'Email', 'Address','City','State')"
'connection string, and database
'driver and the location of database
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;dsn=www.motorlists.com;uid=mechanic; pwd=k1n3t1c;Server.MapPath("motorlists.mdb");"
'ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Database connection open
connection.Open(MM_conn1_STRING)
'executed the SQL
connection.execute(sSQL)
response.write "The form information was inserted successfully."
'Done. Connection closed object ended
connection.Close
Set connection = Nothing
%>
</body>
</html>
any ideas?
stallwoes
Invalid character
/addcust2database.asp, line 25
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;" & _ "dsn=www.motorlists.com;" &_ "uid=mechanic; pwd=k1n3t1c;" &_ "Server.MapPath("motorlists.mdb");"
I'll print the code, but it's pretty long. The purpose is to send a form to database. I was able to rid it once by removing the quotations from motorlists.mdb but then it wouldn't run at all. well here you go:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'variables
Dim fname, lname, Email, CEmail, Address, City, State
Dim MM_conn1_STRING, connection, sSQL
'values from Form, values entered to variables
fname = Request.Form("fname")
lname = Request.Form("lname")
Email = Request.Form("Email")
CEmail = Request.Form("CEmail")
Address = Request.Form("Address")
City = Request.Form("City")
State = Request.Form("State")
'SQL statements and Query
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('fname', 'lname', 'Email', 'Address','City','State')"
'connection string, and database
'driver and the location of database
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;dsn=www.motorlists.com;uid=mechanic; pwd=k1n3t1c;Server.MapPath("motorlists.mdb");"
'ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Database connection open
connection.Open(MM_conn1_STRING)
'executed the SQL
connection.execute(sSQL)
response.write "The form information was inserted successfully."
'Done. Connection closed object ended
connection.Close
Set connection = Nothing
%>
</body>
</html>
any ideas?
stallwoes
•
•
Join Date: Nov 2005
Posts: 4
Reputation:
Solved Threads: 0
ok i've been using the wrong driver and provider etc.. but now I'm having more trouble accessing it. I'm connecting to a remote server I've tried to fix this string but now it's getting worse, any help on my connection string?
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'variables
Dim fname, lname, Email, CEmail, Address, City, State
Dim conn1, connection, sSQL
'values from Form, values entered to variables
fname = Request.Form("fname")
lname = Request.Form("lname")
Email = Request.Form("Email")
CEmail = Request.Form("CEmail")
Address = Request.Form("Address")
City = Request.Form("City")
State = Request.Form("State")
'SQL statements and Query
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('fname', 'lname', 'Email', 'Address','City','State')"
'connection string, and database
'driver and the location of database
conn1="DRIVER={MySQL ODBC 3.51 Driver};SERVER=www.motorlists.com;DATABASE=myDatabase; USER=mechanic;PASSWORD=k1n3t1c;OPTION=3;"
'ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Database connection open
connection.Open(conn1)
'executed the SQL
connection.execute(sSQL)
response.write "The form information was inserted successfully."
'Done. Connection closed object ended
connection.Close
Set connection = Nothing
%>
</body>
</html>
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'variables
Dim fname, lname, Email, CEmail, Address, City, State
Dim conn1, connection, sSQL
'values from Form, values entered to variables
fname = Request.Form("fname")
lname = Request.Form("lname")
Email = Request.Form("Email")
CEmail = Request.Form("CEmail")
Address = Request.Form("Address")
City = Request.Form("City")
State = Request.Form("State")
'SQL statements and Query
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('fname', 'lname', 'Email', 'Address','City','State')"
'connection string, and database
'driver and the location of database
conn1="DRIVER={MySQL ODBC 3.51 Driver};SERVER=www.motorlists.com;DATABASE=myDatabase; USER=mechanic;PASSWORD=k1n3t1c;OPTION=3;"
'ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Database connection open
connection.Open(conn1)
'executed the SQL
connection.execute(sSQL)
response.write "The form information was inserted successfully."
'Done. Connection closed object ended
connection.Close
Set connection = Nothing
%>
</body>
</html>
in the first examples you were using an access database. the last one if for a mysql database.
with the access errors i found that under certain cercamstances (i dont know whick ones tho) the server map path part errors out. try putting the exact path to the database (if one can call access a database to start with).
let me know which database you are using tho
with the access errors i found that under certain cercamstances (i dont know whick ones tho) the server map path part errors out. try putting the exact path to the database (if one can call access a database to start with).
let me know which database you are using tho
•
•
Join Date: Oct 2005
Posts: 3
Reputation:
Solved Threads: 0
Hello
The problem is at the sSQL, it should be as
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('" & fname & "', '" & lname & "', '" & Email & "', '" & Address & "','" & City & "','" & State & "')"
because the fname,lname...etc are variables, this could solve the problem.
The problem is at the sSQL, it should be as
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('" & fname & "', '" & lname & "', '" & Email & "', '" & Address & "','" & City & "','" & State & "')"
because the fname,lname...etc are variables, this could solve the problem.
•
•
•
•
Originally Posted by stallwoes
Alright guys, I'm having quite a time with this one. I'm getting an VB script error : Microsoft VBScript compilation error '800a0408'
Invalid character
/addcust2database.asp, line 25
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;" & _ "dsn=www.motorlists.com;" &_ "uid=mechanic; pwd=k1n3t1c;" &_ "Server.MapPath("motorlists.mdb");"
I'll print the code, but it's pretty long. The purpose is to send a form to database. I was able to rid it once by removing the quotations from motorlists.mdb but then it wouldn't run at all. well here you go:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'variables
Dim fname, lname, Email, CEmail, Address, City, State
Dim MM_conn1_STRING, connection, sSQL
'values from Form, values entered to variables
fname = Request.Form("fname")
lname = Request.Form("lname")
Email = Request.Form("Email")
CEmail = Request.Form("CEmail")
Address = Request.Form("Address")
City = Request.Form("City")
State = Request.Form("State")
'SQL statements and Query
sSQL = "INSERT INTO motorlists.tblcustomer VALUES ('fname', 'lname', 'Email', 'Address','City','State')"
'connection string, and database
'driver and the location of database
MM_conn1_STRING="Provider=Microsoft.Generic.OLEDB.3.51;dsn=www.motorlists.com;uid=mechanic; pwd=k1n3t1c;Server.MapPath("motorlists.mdb");"
'ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Database connection open
connection.Open(MM_conn1_STRING)
'executed the SQL
connection.execute(sSQL)
response.write "The form information was inserted successfully."
'Done. Connection closed object ended
connection.Close
Set connection = Nothing
%>
</body>
</html>
any ideas?
stallwoes
![]() |
Similar Threads
- Problem connecting to the database after changing the database server (ASP.NET)
- ASP.NET: Connecting to database (ASP.NET)
- Error connecting to database (ASP.NET)
- struggling with connecting database to server (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: How to study ASP???
- Next Thread: Inserting Images to a Datagrid
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





