Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Trogan
Starting Member
3 Posts |
Posted - 2008-12-05 : 14:16:40
|
Hi,I'm trying to create a register form and I'm following the instructions in the "Dreamweaver MX Unleashed" book by Pizzi, M and Ruvalcaba, Z. The problem I'm having is that when I submit the details from my register form it should get entered into my Access database; however, I receive the following error upon submitting the form.ADODB.Command error '800a0d5d'Application uses a value of the wrong type for the current operation./teaofasia/register.asp, line 41 This is the line in question:MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 6, Request.Form("billingcity")) ' adVarWChar ----------Here is my code from the register.asp page:ASP code that comes before the <html> tag:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="../Connections/con_ecom.asp" --><%Dim MM_editActionMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)End If' boolean to abort record editDim MM_abortEditMM_abortEdit = false%><%' IIf implementationFunction MM_IIf(condition, ifTrue, ifFalse) If condition = "" Then MM_IIf = ifFalse Else MM_IIf = ifTrue End IfEnd Function%><%If (CStr(Request("MM_insert")) = "register") Then If (Not MM_abortEdit) Then ' execute the insert Dim MM_editCmd Set MM_editCmd = Server.CreateObject ("ADODB.Command") MM_editCmd.ActiveConnection = MM_con_ecom_STRING MM_editCmd.CommandText = "INSERT INTO Customers (FirstName, LastName, Username, Password, Email, PhoneNumber, BillingAddress, BillingCity, BillingPostCode, ShippingAddress, ShippingCity, ShippingPostCode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 25, Request.Form("fname")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 10, Request.Form("lname")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("username")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 25, Request.Form("password")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("email")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 5, 1, -1, MM_IIF(Request.Form("phonenumber"), Request.Form("phonenumber"), null)) ' adDouble MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 20, Request.Form("billingaddress")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 6, Request.Form("billingcity")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 255, Request.Form("billingpostcode")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 255, Request.Form("shippingaddress")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 202, 1, 255, Request.Form("shippingcity")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 202, 1, 255, Request.Form("shippingpostcode")) ' adVarWChar MM_editCmd.Execute MM_editCmd.ActiveConnection.Close ' append the query string to the redirect URL Dim MM_editRedirectUrl MM_editRedirectUrl = "index4.asp" If (Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If Response.Redirect(MM_editRedirectUrl) End IfEnd If%><%Dim rsCustomersDim rsCustomers_cmdDim rsCustomers_numRowsSet rsCustomers_cmd = Server.CreateObject ("ADODB.Command")rsCustomers_cmd.ActiveConnection = MM_con_ecom_STRINGrsCustomers_cmd.CommandText = "SELECT Customers.*, CreditCards.* FROM Customers INNER JOIN CreditCards ON Customers.CustomerID = CreditCards.CustomerID;" rsCustomers_cmd.Prepared = trueSet rsCustomers = rsCustomers_cmd.ExecutersCustomers_numRows = 0%>My register form...<div align="center" style="position:absolute; top:23px; left: 179px; height: 495px;"><form name="register" action="<%=MM_editAction%>" method="POST"><table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" bgcolor="#00CC33"><span class="style3">Personal Information</span></td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td><span class="style1">First Name:</span></td> <td><label> <input type="text" name="fname" id="fname"> </label></td> </tr> <tr> <td><span class="style1">Last Name:</span></td> <td><label> <input type="text" name="lname" id="lname"> </label></td> </tr> <tr> <td><span class="style1">Username:</span></td> <td><label> <input type="text" name="username" id="username"> </label></td> </tr> <tr> <td><span class="style1">Password:</span></td> <td><label> <input type="text" name="password" id="password"> </label></td> </tr> <tr> <td><span class="style1">Email:</span></td> <td><label> <input type="text" name="email" id="email"> </label></td> </tr> <tr> <td><span class="style1">Phone Number:</span></td> <td><label> <input type="text" name="phonenumber" id="phonenumber"> </label></td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td colspan="2" bgcolor="#00CC33"><span class="style3">Billing Information</span></td> <td> </td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td><span class="style1">Credit Card:</span></td> <td><label> <select name="cctype" id="cctype"> </select> </label></td> </tr> <tr> <td><span class="style1">Expiry Date:</span></td> <td><label> <select name="ccexpiry" id="ccexpiry"> </select> </label></td> </tr> <tr> <td><span class="style1">Billing Address:</span></td> <td><label> <input type="text" name="billingaddress" id="billingaddress"> </label></td> </tr> <tr> <td><span class="style1">Billing City:</span></td> <td><label> <input type="text" name="billingcity" id="billingcity"> </label></td> </tr> <tr> <td><span class="style1">Billing Postcode/ZIP</span></td> <td><label> <input type="text" name="billingpostcode" id="billingpostcode"> </label></td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td colspan="2" bgcolor="#00CC33"><span class="style3">Shipping Information</span></td> <td> </td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td><span class="style1">Shipping Address:</span></td> <td><label> <input type="text" name="shippingaddress" id="shippingaddress"> </label></td> </tr> <tr> <td><span class="style1">Shipping City:</span></td> <td><label> <input type="text" name="shippingcity" id="shippingcity"> </label></td> </tr> <tr> <td><span class="style1">Shipping Postcode/ZIP:</span></td> <td><label> <input type="text" name="shippingpostcode" id="shippingpostcode"> </label></td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td colspan="2"><span class="style1"> <label> <input name="btnSubmit" type="submit" id="btnSubmit" onClick="MM_validateForm('fname','','R','lname','','R','username','','R','password','','R','email','','NisEmail','phonenumber','','RisNum','billingaddress','','R','billingcity','','R','billingpostcode','','R','shippingaddress','','R','shippingcity','','R','shippingpostcode','','R');return document.MM_returnValue" value="Submit"> </label> <label> <input type="submit" name="btnReset" id="btnReset" value="Reset"> </label> </span></td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr> <tr> <td><span class="style1"></span></td> <td> </td> </tr></table><input type="hidden" name="MM_insert" value="register"></form></div>I've been trying to solve this for some time now with no luck. If someone could help me with this, it would be appreciated.Thanks! |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-12-05 : 15:38:39
|
hi Trogan,check your database, It probably means that you are using the wrong lenght for your data lenght.In your ASP code you are usingMM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 6, Request.Form("billingcity")) ' adVarWChar which means the lenght of the data type is 6. Check your DB field to see if its the same or being truncated ? |
|
|
Trogan
Starting Member
3 Posts |
Posted - 2008-12-05 : 16:10:14
|
Hi Afrika, thanks for the quick reply. Yes, the length was 6 characters in my Database. I have changed the length to 50 and I don't receive any errors now. However, I hope you can help me one more problem? According to the book I'm reading, it says that after clicking Submit on my form, the details should be entered into the Database but nothing gets entered. Would you know what could be causing this? I need to make a login page after with user details stored in the database so I really need to get the registration form fixed first.Thank you again! |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-12-06 : 04:31:47
|
Look at your command text. Looks very wrong to me.Dreamweaver as code snippets for inserts, updates, delete, stored procedures, logins etcIf not write one yourself, quite easy |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-12-06 : 04:39:12
|
I would also advice, if you are learning programming with classic ASP, I would advice you to move to .net.Its a lot more difficult, but by far more rewarding |
|
|
Trogan
Starting Member
3 Posts |
Posted - 2008-12-09 : 14:30:10
|
Apologies for not replying sooner. I managed to get my previous problem solved and the register form is getting saved to my remote database. I may need some advice soon on another problem, but for now thank you for your help Afrika. |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-12-10 : 17:08:15
|
glad2help |
|
|
|
|
|
|
|