Solved

asp error

Posted on 2011-09-23
7
307 Views
Last Modified: 2012-05-12
Microsoft JET Database Engine error '80040e10'

No value given for one or more required parameters.

/anoopm/dvdshop/checkout.asp, line 124


I am trying to create two connection objects and connect to to access databases.  
conn1
objConn2.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =" & server.MapPath ("shop-2.mdb")
conn2
objConn2.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =" & server.MapPath ("shop.mdb")
<%

Dim objConn2, objRS2,Sql2
set objConn2=server.CreateObject("ADODB.Connection")
set objRS2=server.CreateObject("ADODB.Recordset")


' Modify this line if you want to use a different database connection. 
objConn2.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =" & server.MapPath ("shop.mdb")


sql="select * from orders where basket_id="&basket_id
sql2="select * from tblUsers where username="&trim(strUserName)
 
	set objrs=objconn.execute(sql)
	set objRS2=objConn2.execute(sql2) ----->error at this line

Open in new window

0
Comment
Question by:n0ttytechy
  • 4
  • 3
7 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 36586779
I think I got it all done correctly, you may have to change a few things to make it work for you.

Good Luck
Carrzkiss

<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop.mdb") & ";"
objConn.Open

Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop-2.mdb") & ";"
objConn2.Open


Set sql = CreateObject("ADODB.Command")
sql.ActiveConnection=objConn
sql.Prepared = true
sql.commandtext = "select * from orders where basket_id=?"
sql.Parameters.Append sql.CreateParameter("@basket_id", 3, 1, , basket_id)
set rs = sql.execute

Set sql2 = CreateObject("ADODB.Command")
sql2.ActiveConnection=objConn2
sql2.Prepared = true
sql2.commandtext = "select * from tblUsers where username=?"
sql2.Parameters.Append sql2.CreateParameter("@username", 200, 1, , trim(strUserName))
set rs2 = sql2.execute

%>

Open in new window

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 36586801
One thing I did not correct in the code.
Using the wildcard in your select statement is not a good idea.

Add in all the column names that belong in the statement that are going to be used.

<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop.mdb") & ";"
objConn.Open

Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop-2.mdb") & ";"
objConn2.Open


Set sql = CreateObject("ADODB.Command")
sql.ActiveConnection=objConn
sql.Prepared = true
sql.commandtext = "select basket_id from orders where basket_id=?"
sql.Parameters.Append sql.CreateParameter("@basket_id", 3, 1, , basket_id)
set rs = sql.execute

Set sql2 = CreateObject("ADODB.Command")
sql2.ActiveConnection=objConn2
sql2.Prepared = true
sql2.commandtext = "select username from tblUsers where username=?"
sql2.Parameters.Append sql2.CreateParameter("@username", 200, 1, , trim(strUserName))
set rs2 = sql2.execute

%>

Open in new window

0
 

Author Comment

by:n0ttytechy
ID: 36586872
gives me the following error at
line: sql2.Parameters.Append sql2.CreateParameter("@username", 200, 1, , trim(strUserName))

ADODB.Parameters error '800a0e7c'

Parameter object is improperly defined. Inconsistent or incomplete information was provided.

/anoopm/dvdshop/checkout.asp, line 130
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:n0ttytechy
ID: 36586883
i need to use wildcard because somewhere bottom in the code i use all the fields from the the table users and basket
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
ID: 36586950
If you have to use them all, then list them all.

Try this

<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop.mdb") & ";"
objConn.Open

Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("shop-2.mdb") & ";"
objConn2.Open


Set sql = CreateObject("ADODB.Command")
sql.ActiveConnection=objConn
sql.Prepared = true
sql.commandtext = "select basket_id from orders where basket_id=?"
sql.Parameters.Append sql.CreateParameter("@basket_id", 3, 1, , basket_id)
set rs = sql.execute

Set sql2 = CreateObject("ADODB.Command")
sql2.ActiveConnection=objConn2
sql2.Prepared = true
sql2.commandtext = "select username from tblUsers where username=?"
' the 25 is the number of characters that are set in the field
' Change it to what you have your column set at
sql2.Parameters.Append sql2.CreateParameter("@username", 200, 1, 25, trim(strUserName))
set rs2 = sql2.execute

%>

Open in new window

0
 

Author Comment

by:n0ttytechy
ID: 36587037
so does this mean that i will have  10 such lines if i have 10 columns?
sql2.Parameters.Append sql2.CreateParameter("@username", 200, 1, 25, trim(strUserName))

what about columns which are not text, numbers, i just leave it blank like basket_id?
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 36587108
Yes, please read this article here.
http://www.experts-exchange.com/A_3626.html

What this does is help protect your database from SQL Injections.
In the link above, you will also see a Function called: ProtectSQL
This is a function that I wrote, to help protect SQL and XSS Injections.

You should be able to find all the information that you need in the link above.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question