Solved

asp error

Posted on 2011-09-23
7
303 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determining if Request.Form is empty 1 47
CSS Question.. 3 85
Problems using Provider=OraOLEDB.Oracle via VBScript/Classic ASP 5 66
ASP server side get value 15 21
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…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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