473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help! --> ADODB

bmallett
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
  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 1874
jhardman
3,406 Recognized Expert Specialist
Check out the method in the "How-to" section, I think it runs a bit smoother.

Jared
Jan 29 '08 #2
CroCrew
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
  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
2280
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");
2
1367
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"
3
1270
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.");
4
1602
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>
1
1321
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
5
1961
by: njsimha | last post by:
Hi, In the folowing XML snippet: <template1> <name>student</name> <elem1> <subelem1>65</subelem1> <subelem2>15</subelem2> </elem1>
16
2601
by: njsimha | last post by:
Hi, I have the following XML snippet: <root> <template1> <elem1>1000</elem1> <elem2> <subelem1>65</subelem1>
2
3171
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>
0
10363
Oralloy
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...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
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...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.