By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,977 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,977 IT Pros & Developers. It's quick & easy.

Need Help! --> ADODB

bmallett
P: 2
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
Share this Question
Share on Google+
2 Replies


jhardman
Expert 2.5K+
P: 3,405
Check out the method in the "How-to" section, I think it runs a bit smoother.

Jared
Jan 29 '08 #2

CroCrew
Expert 100+
P: 563
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

Post your reply

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