473,847 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help! --> ADODB

2 New Member
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.CreateParam eter("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
  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
  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")
  30. 'Opening Connection to Database
  31. Conn.open  connStr
  33. 'If not blank Username password submitted
  34. if UserName <> "" or Password <> "" then
  36.     'Recordset and Query to be executed
  37.     rs = "select * from [user] where UN = '"&UserName&"' AND PW = '"&Password&"'"
  39.     'Retrieving recordset by executing SQL
  40.     'set rs=Conn.execute(SQLQuery)
  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
  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
  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
  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 1883
3,406 Recognized Expert Specialist
Check out the method in the "How-to" section, I think it runs a bit smoother.

Jan 29 '08 #2
564 Recognized Expert Contributor
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
  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")
  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
  41.     Response.Write("You are currently login in.")
  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. %>
Jan 29 '08 #3

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

Similar topics

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 6 hours wrong. The time should be GMT minus 6 hours. Can anyone help me with that? Her's the code: <?php header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
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 = CreateObject("Msxml2.DOMDocument.4.0") Set oCmd = CreateObject("ADODB.Command") oCmd.ActiveConnection = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=TestXML;UID=sa;Password=123456"
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 StringBuilder(); s.Append("<SCRIPT LANGUAGE='JavaScript'>"); s.Append("function SetInitialFocus()"); s.Append("{"); s.Append(" document.");
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> <SPECIAL1>abc</SPECIAL1> <SPECIAL2>abc</SPECIAL2> ... <SPECIAL12>abc</SPECIAL9>
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 ADODB.Connection Dim rs As New ADODB.Recordset Private Sub Form_Load() Set rs = New ADODB.Recordset
by: njsimha | last post by:
Hi, In the folowing XML snippet: <template1> <name>student</name> <elem1> <subelem1>65</subelem1> <subelem2>15</subelem2> </elem1>
by: njsimha | last post by:
Hi, I have the following XML snippet: <root> <template1> <elem1>1000</elem1> <elem2> <subelem1>65</subelem1>
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>
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.