Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp error

Posted on 2011-09-23
7
Medium Priority
?
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 31

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 31

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 31

Accepted Solution

by:
Wayne Barron earned 2000 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 31

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

688 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