473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need Help! --> ADODB

bmallett
I am getting the following error:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/dcme/newframe/verify.asp, line 48


Line 48 is:

cmd.Parameters.Append cmd.CreateParameter("UN", adVarChar, adParamInput, 10)

My table is set to text and 10 char

My code is here:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'Connection String
  3. Dim Conn
  4. 'Query to be executed
  5. Dim SQLQuery
  6. 'Recordset
  7. Dim rs
  8. 'UN Of Logged in user
  9. Dim UserName
  10. 'PW of User
  11. Dim Password
  12.  
  13. 'Getting information from submitted form
  14. UserName = UCase(request.form("username"))
  15. Password = UCase(request.form("password"))
  16. RememberMe = request.form("rememberme")
  17. NewPassword = request.form("newpassword")
  18. NewUser = request.form("newuser")
  19. SessionID=Session.SessionID
  20.  
  21. 'Creating connection Object
  22. set Conn=server.createobject("ADODB.Connection")
  23. Conn.Mode = 3
  24. 'Creating Recordset Object
  25. 'set rs = Server.CreateObject("ADODB.Recordset")
  26. 'Initialising Provider String
  27. connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="
  28. connStr = connStr + server.MapPath("db/frame.mdb")
  29.  
  30. 'Opening Connection to Database
  31. Conn.open  connStr
  32.  
  33. 'If not blank Username password submitted
  34. if UserName <> "" or Password <> "" then
  35.  
  36.     'Recordset and Query to be executed
  37.     rs = "select * from [user] where UN = '"&UserName&"' AND PW = '"&Password&"'"
  38.  
  39.     'Retrieving recordset by executing SQL
  40.     'set rs=Conn.execute(SQLQuery)
  41.  
  42.     'If New User selected
  43.         if NewUser = "ON" then
  44.         'Create Entry
  45.         Set cmd = Server.CreateObject("ADODB.Command")
  46.         Set cmd.ActiveConnection = Conn
  47.         cmd.CommandText = "insert into [user] (UN, PW, ssid) values (?, ?, ?)"
  48.         cmd.Parameters.Append cmd.CreateParameter("UN", adVarChar, adParamInput, 10)
  49.         cmd.Parameters.Append cmd.CreateParameter("PW", adVarChar, adParamInput, 10)
  50.         cmd.Parameters.Append cmd.CreateParameter("ssid", adVarChar, adParamInput, 50)
  51.         cmd.Parameters("UN") = UserName
  52.         cmd.Parameters("PW") = Password
  53.         cmd.Parameters("ssid") = SessionID
  54.         cmd.Execute
  55.     else
  56.         end if
  57.  
  58.     'If New Password selected
  59.         if NewPassword = "ON" then
  60.             'Update Password
  61.         Set cmd = Server.CreateObject("ADODB.Command")
  62.         Set cmd.ActiveConnection = Conn
  63.         cmd.CommandText = "UPDATE user SET PW="& Password &" WHERE UN="+ UserName +""
  64.         cmd.Execute
  65.     else
  66.         end if
  67.  
  68.         'If remember me selected
  69.         if RememberMe = "ON" then
  70.             'Writing cookies permanently
  71.             Response.Cookies("UserName")=UserName
  72.             Response.Cookies("Password")=Password
  73.             Response.Cookies("UserName").Expires = Now() + 365
  74.             Response.Cookies("Password").Expires = Now() + 365
  75.             Response.Redirect "basicinfo.asp"
  76.         else
  77.             'writing cookies temporarily
  78.             Response.Cookies("UserName")=UserName
  79.             Response.Cookies("Password")=Password
  80.             Response.Redirect "basicinfo.asp"
  81.         end if
  82.  
  83.     'If no records retrieved
  84.     if rs.BOF and rs.EOF then
  85.         Response.Redirect "Signon.asp?username=" & UserName
  86.     else 
  87.         'Closing all database connections
  88.         Conn.Close
  89.         rs.close   
  90.         set rs = nothing
  91.         set Conn = nothing
  92.     end if
  93. else
  94.     'Invalid User
  95.     Response.Redirect "Signon.asp?UserName=blank"
  96. end if
  97. %>
Jan 23 '08 #1
2 1856
jhardman
3,406 Expert 2GB
Check out the method in the "How-to" section, I think it runs a bit smoother.

Jared
Jan 29 '08 #2
CroCrew
564 Expert 512MB
Hello bmallett,

You might want to take another look at how your code is set to run and also your database. Table names should not use reserved names within your database. Here is a stab at cleaning/thinning out your code. Please be advised I tried to keep inline with what your were trying to do so even my code is not truly optimized. PM me if you want to talk more in person.

Hope this helps~

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     xUserName = replace(request.form("UserName"),"'","''") '<-- User's Name.
  3.     xPassword = replace(request.form("Password"),"'","''") '<-- User's current password.
  4.     xNewPassword = replace(request.form("NewPassword"),"'","''") '<-- New password to be saved if ChangePassword value is true.
  5.     xNewUser = request.form("NewUser") '<-- Make this a boolean (true or false) value.
  6.     xChangePassword = request.form("ChangePassword") '<-- Make this a boolean (true or false) value.
  7.     xRememberMe = request.form("RememberMe") '<-- Make this a boolean (true or false) value.
  8.     xSessionID = Session.SessionID
  9.  
  10.     Set adoCon = Server.CreateObject("ADODB.Connection")
  11.     adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/frame.mdb") 
  12.     Set rsUpdate = Server.CreateObject("ADODB.Recordset")
  13.  
  14.     If (xNewUser) Then 
  15.         strSQL = "SELECT TOP 1 * FROM [user]"
  16.         rsUpdate.CursorType = 2
  17.         rsUpdate.LockType = 3
  18.         rsUpdate.Open strSQL, adoCon
  19.         rsUpdate.AddNew
  20.         rsUpdate.Fields("UN").Value = xUserName
  21.         rsUpdate.Fields("PW").Value = xPassword
  22.         rsUpdate.Fields("ssid").Value = xSessionID 
  23.         rsUpdate.Update
  24.         Response.Write("New user has been added.<br>")
  25.     Else
  26.         strSQL = "SELECT * FROM [user] WHERE UN = '" & xUserName & "' AND PW = '" & xPassword & "'"
  27.         rsUpdate.CursorType = 2
  28.         rsUpdate.LockType = 3
  29.         rsUpdate.Open strSQL, adoCon
  30.         If ((rsUpdate.EOF) OR (((StrComp(xPassword, rsUpdate("PW").value) = 0)) Then
  31.             Response.Write("The combination of UserName and Current Password is bad!")
  32.             Response.end
  33.         End If
  34.         If (NewPassword) Then
  35.             rsUpdate.Fields("PW") = xNewPassword 
  36.             rsUpdate.Update 
  37.             Response.Write("Password has been changed.<br>")
  38.         End If
  39.     End If
  40.  
  41.     Response.Write("You are currently login in.")
  42.  
  43.     If (xRememberMe) Then
  44.         Response.Cookies("LocalUser")("CookieTest") = "true"
  45.         If Request.Cookies("LocalUser")("CookieTest") Then
  46.             Response.Cookies("LocalUser")("UserName") = xUserName
  47.             Response.Cookies("LocalUser")("Password") = xPassword
  48.             Response.Cookies("LocalUser").Expires = (Now() + 365)
  49.         Else
  50.             Response.Write("But, you will not be remembered because your cookies are disabled.")
  51.         End If
  52.     End If
  53. %>
  54.  
Jan 29 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gerry | last post by:
As I'm not a PHP-prgrammer at all, I just need Help with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time...
2
by: serge | last post by:
Using some VB sample code on the Internet I have the following that works well and exports a set of records to an XML file: Dim oCmd, sSQL, oDom Set oDom =...
3
by: Eirik Eldorsen | last post by:
I'm tring to translate an VB.NET method into C#. Here is what I've done so far. Need help on the while loop public static void SetInitialFocus(Control ctrl) { StringBuilder s = new...
4
by: Piper707 | last post by:
I need help with using a general template which would process all tags other than the ones for which specific templates have been written. My XML looks like this: <ITEMS>...
1
by: pramodrepaka | last post by:
i am not able to add records with the help of ADODB. what is the problem i am not able to understand please help me. this is the code i written In General Declaration Dim cn As New...
5
by: njsimha | last post by:
Hi, In the folowing XML snippet: <template1> <name>student</name> <elem1> <subelem1>65</subelem1> <subelem2>15</subelem2> </elem1>
16
by: njsimha | last post by:
Hi, I have the following XML snippet: <root> <template1> <elem1>1000</elem1> <elem2> <subelem1>65</subelem1>
2
by: njsimha | last post by:
Hi, I have a query regarding the selection of a particular tag based on a condition. In the following XML code: <root> <template1> <elem1>1000</elem1> <elem2>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.