Solved

asp error

Posted on 2011-09-23
7
299 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:n0ttytechy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

12 Experts available now in Live!

Get 1:1 Help Now