This should be a simple fix...

D

ddobrzenski

I am getting error messages with my ASP below. I don't have much experience
in this coding, so hopefully someone will be able to fix my code and get me
on my way.

Thanks,

Danny

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
</head>

<body>
<%
' Declaring variables
Dim name, email, phone, username, password, location, contact,
data_source, con, sql_insert

' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function

' Receiving values from Form
names = ChkString(Request.Form("name"))
email = ChkString(Request.Form("email"))
phone = ChkString(Request.Form("phone"))
username = ChkString(Request.Form("username"))
passwords = ChkString(Request.Form("password"))
location = ChkString(Request.Form("location"))
contact = ChkString(Request.Form("contact"))

data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("\db/mainnew.mdb")
sql_insert = "insert into customers (name, email, phone, username,
password, location, contact) values ('" & _
name & "', '" & email & "', '" & phone& "', '" & username& "',
'" & password& "', '" & location& "', '" & contact & "')"

' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "Congratulations, all information was loaded into database."
%>



</body>
</html>
 
D

Duane Hookom

You might want to use Response.Write() in your code to display the
sql_insert. Also, your page should display the error message with a suggested
line. We can't see this from where we sit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top