Solved

asp error

Posted on 2011-09-23
7
300 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now