I have been trying for several dys now to just get the code to work on a form to add a record to y MySQL database. I've been trying to use various samples online as my experience with ASP and .NET is limited. I am, however, an advanced VB and VBA programmer, but using VS2013 Premium sems to have some major coding differences.

I need help. My code is at the bottom of the page. There are two files. This is the error I get in Visual Studio:

Name:  VS Error.jpg
Views: 1121
Size:  36.4 KB

I do not get an error in the browser, rather it keeps spinning because VS breaks at the point of the error.

Here is the code for the Contact Us form:

<%@ Page aspcompat=true %>
<html>
<head>
<title>Mailing List Sign-Up</title>
<style type="text/css">
.auto-style1 {
width: 256px;
}
</style>
</head>
<body>
<form action="asp_mysql_insert_cust.aspx" name="frmContactUs" method="post">
<table border="1">
<tr>
<th class="auto-style1"> <div>First Name </div></th><td><div><input type="text" name="txtFName" size="30"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Last Name </div></th><td><div><input type="text" name="txtLName" size="30"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Company </div></th><td><div><input type="text" name="txtCompany" size="100"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Address 1 </div></th><td><div><input type="text" name="txtAddr1" size="100"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Address 2 </div></th><td><div><input type="text" name="txtAddr2" size="100"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>City </div></th><td><div><input type="text" name="txtCity" size="30"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>2-Character State Code </div></th><td><div><input type="text" name="txtState" size="2" style="width: 50px"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Postal </div></th><td><div><input type="text" name="txtPostal" size="10"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Primary Phone </div></th><td><div><input type="text" name="txtPhone1" size="14"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Secondary Phone/Fax </div></th><td><div><input type="text" name="txtPhone2" size="14"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Email </div></th><td><div><input type="text" name="txtEmail" size="80"></div></td>
</tr>
<tr>
<th class="auto-style1"> <div>Website URL </div></th><td><div><input type="text" name="txtWebsite" size="120"></div></td>
</tr>
</table>
<input type="submit" name="submit" value="Add me to the list!">
</form>
</body>
</html>
Here is the code with the SQL:

<%@ Page aspcompat=true %>

<html>
<head>
<title>Mailing List Sign-Up</title>
</head>
<body>
<%
Dim Conn As Object, strSQL As String, objExec, ConnString As String
Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "MySQL ODBC 5.1 Driver"
ConnString = "SERVER='MYSQL5002.Smarterasp.net';UID=USERID;pwd='PASSWORD';database='DATABASE';"
Conn.Open(ConnString)
strSQL = ""
strSQL = strSQL & "INSERT INTO customers "
strSQL = strSQL & "(FName,LName,Company,Addr1,Addr2,City,State,Postal,Phone1,Phone2,Email,Website,Mailing_List) "
strSQL = strSQL & "VALUES "
strSQL = strSQL & "('" & Request.Form("txtFName") & "','" & Request.Form("txtLName") & "', '" & Request.Form("txtCompany") & "' "
strSQL = strSQL & "'" & Request.Form("txtAddr1") & "','" & Request.Form("txtAddr2") & "', '" & Request.Form("txtCity") & "' "
strSQL = strSQL & "'" & Request.Form("txtState") & "','" & Request.Form("txtPostal") & "', '" & Request.Form("txtPhone1") & "' "
strSQL = strSQL & "'" & Request.Form("txtPhone2") & "','" & Request.Form("txtEmail") & "', '" & Request.Form("txtWebsite") & "' "
strSQL = strSQL & ", 1);"
objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save completed.")
Else
Response.Write("Error in SQL statement: " & strSQL & ". Error: " & Err.Description)
End If
Conn.Close()
objExec = Nothing
Conn = Nothing
%>
</body>
</html>