473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Prepared statements in ASP

I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did try
to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction. What
am I doing incorrectly here?

thanks
Jul 22 '05 #1
8 9257
No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did try
to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction. What am
I doing incorrectly here?

thanks

http://www.aspfaq.com/show.asp?id=2112

You may be interested in my command object code generator available here
(it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear

If your procedure has no output parameters, and you aren't interested in
reading the Return parameter, then you don't need an explicit command
object. See http://tinyurl.com/jyy0

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2
Bob Barrows [MVP] wrote:
No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did try
to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction. What am
I doing incorrectly here?

thanks
http://www.aspfaq.com/show.asp?id=2112


Ugh....how do I know which MDAC I have?

You may be interested in my command object code generator available here
(it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear


All I see here is how to call a stored procedure. I'm not calling a
stored proc, I want to make a prepared statement. Something like this:

UPDATE FOO_TABLE SET foName = @name, foPhone = @phone WHERE foId = @id

And then fill the parameters in at run time.

If I missed something on the page, please let me know.

Jul 22 '05 #3
No one wrote:
Bob Barrows [MVP] wrote:
No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did
try to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction.
What am I doing incorrectly here?

thanks
http://www.aspfaq.com/show.asp?id=2112


Ugh....how do I know which MDAC I have?


I suggest creating a simple asp page with the following two lines of code:

<%
set cn=createobject("adodb.connection")
response.write cn.Version
%>

Alternatively, you can #include the adovbs.inc file, but as Aaron's article
states, that file has many more constants than you will likely need.

You may be interested in my command object code generator available
here (it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear


All I see here is how to call a stored procedure. I'm not calling a
stored proc, I want to make a prepared statement. Something like
this:
UPDATE FOO_TABLE SET foName = @name, foPhone = @phone WHERE foId = @id

And then fill the parameters in at run time.

If I missed something on the page, please let me know.


I thought you were talking about a stored procedure. I think this is what
you are asking about:
http://groups-beta.google.com/group/...e36562fee7804e

You don't need to build the parameters collection.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #4
Bob Barrows [MVP] wrote:
No one wrote:
Bob Barrows [MVP] wrote:

No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did
try to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction.
What am I doing incorrectly here?

thanks

http://www.aspfaq.com/show.asp?id=2112


Ugh....how do I know which MDAC I have?

I suggest creating a simple asp page with the following two lines of code:

<%
set cn=createobject("adodb.connection")
response.write cn.Version
%>

Alternatively, you can #include the adovbs.inc file, but as Aaron's article
states, that file has many more constants than you will likely need.

You may be interested in my command object code generator available
here (it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear


All I see here is how to call a stored procedure. I'm not calling a
stored proc, I want to make a prepared statement. Something like
this:
UPDATE FOO_TABLE SET foName = @name, foPhone = @phone WHERE foId = @id

And then fill the parameters in at run time.

If I missed something on the page, please let me know.

I thought you were talking about a stored procedure. I think this is what
you are asking about:
http://groups-beta.google.com/group/...e36562fee7804e

You don't need to build the parameters collection.

Bob Barrows


I guess ODBC for MS SQL server doesn't support named parameters under
ADO. Ok.
Jul 22 '05 #5
Bob Barrows [MVP] wrote:
No one wrote:
Bob Barrows [MVP] wrote:

No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did
try to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction.
What am I doing incorrectly here?

thanks

http://www.aspfaq.com/show.asp?id=2112


Ugh....how do I know which MDAC I have?

I suggest creating a simple asp page with the following two lines of code:

<%
set cn=createobject("adodb.connection")
response.write cn.Version
%>

Alternatively, you can #include the adovbs.inc file, but as Aaron's article
states, that file has many more constants than you will likely need.

You may be interested in my command object code generator available
here (it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear


All I see here is how to call a stored procedure. I'm not calling a
stored proc, I want to make a prepared statement. Something like
this:
UPDATE FOO_TABLE SET foName = @name, foPhone = @phone WHERE foId = @id

And then fill the parameters in at run time.

If I missed something on the page, please let me know.

I thought you were talking about a stored procedure. I think this is what
you are asking about:
http://groups-beta.google.com/group/...e36562fee7804e

You don't need to build the parameters collection.

Bob Barrows


I changed the SQL to use this instead of the named params:

peopleUpdateSQL = "UPDATE People SET FirstName = ?, surname = ? WHERE id
= ?"
I create an array of my values like so:

updatedFirstName = peopleSourceRS("firstname")
updatedSurName = peopleSourceRS("surname")
whereId = peopleSourceRS("id")

Dim params
params = array(updatedFirstName, updatedSurName, whereId)

and I execute like so:

peopleUpdate.Execute , array(updatedFirstName, updatedSurName, whereId),
adExecuteNoRecords

I get this error on the browser:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E57)
[Microsoft][ODBC SQL Server Driver]String data, right truncation
/RepLocator/ProcessPeopleFile.asp, line 113

------------------------------------------
I'm not sure what is getting truncated.
Jul 22 '05 #6
Bob Barrows [MVP] wrote:
No one wrote:
Bob Barrows [MVP] wrote:

No one wrote:
I am trying to create a prepared statement in ASP, but am having
problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

The server doesn't seem to like adVarChar and adParamInput. I did
try to create the parameter without arguments and then assign the
properties, but it gives the same error for .Type and .Direction.
What am I doing incorrectly here?

thanks

http://www.aspfaq.com/show.asp?id=2112


Ugh....how do I know which MDAC I have?

I suggest creating a simple asp page with the following two lines of code:

<%
set cn=createobject("adodb.connection")
response.write cn.Version
%>

Alternatively, you can #include the adovbs.inc file, but as Aaron's article
states, that file has many more constants than you will likely need.

You may be interested in my command object code generator available
here (it's free):

http://www.thrasherwebdesign.com/ind...asp&c=&a=clear


All I see here is how to call a stored procedure. I'm not calling a
stored proc, I want to make a prepared statement. Something like
this:
UPDATE FOO_TABLE SET foName = @name, foPhone = @phone WHERE foId = @id

And then fill the parameters in at run time.

If I missed something on the page, please let me know.

I thought you were talking about a stored procedure. I think this is what
you are asking about:
http://groups-beta.google.com/group/...e36562fee7804e

You don't need to build the parameters collection.

Bob Barrows

I looked at this code, but it seems, for update at least, that the error
code trap is backwards. WHen the update happened fine, err contained a
0. When the update didn't occure, the error code was -2147217833.
Jul 22 '05 #7
No one wrote:
updatedFirstName = peopleSourceRS("firstname")
updatedSurName = peopleSourceRS("surname")
whereId = peopleSourceRS("id")

Dim params
params = array(updatedFirstName, updatedSurName, whereId)

and I execute like so:

peopleUpdate.Execute , array(updatedFirstName, updatedSurName,
whereId), adExecuteNoRecords
You already had an array. Why create a new one?

My normal practice is to be explicit about my datatypes. Is whereid numeric?
If so, explicitly convert it to the appropriate numeric subtype. Assuming
int:

params = array(updatedFirstName, updatedSurName, _
clng(whereId))

peopleUpdate.Execute , params, _
adExecuteNoRecords + adCmdText

I get this error on the browser:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E57)
[Microsoft][ODBC SQL Server Driver]String data, right truncation
/RepLocator/ProcessPeopleFile.asp, line 113

This is usually a warning. The update should have occurred. You should
probably use Left() to make sure the string you send to this statement is
not too long for the field into which it is going to be put.

You should be using the sqloledb OLE DB provider instead of the ODBC driver:
http://www.aspfaq.com/show.asp?id=2126
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #8
Maybe could you have a read on this, it's in french but the sample code
might help you:
http://dotnetjunkies.com/WebLog/afon.../29/27120.aspx

Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
hello! mysqli in PHP5 comes with prepared statements functionality. However, without persistent connections or connection pooling in this code library, one has to ask: why bother? are...
0
by: David.Tymon | last post by:
>Description: MySQL v4.1.0-alpha only allows a client to prepare a maximum of 254 statements. On the 255th mysql_prepare() call, a failure is returned with no information returned by...
1
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the...
0
by: Prashanth | last post by:
I am getting this error from BEA DB2 Driver in weblogic console. java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE We keep...
2
by: Cyril VELTER | last post by:
I'm converting an application to use the V3 protocol features in the 7.4 libpq. As I need to make a design choice regarding the use of prepared statements, I'm wondering what ressources does a...
2
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar...
2
by: Pugi! | last post by:
It is by accident that I noticed that I forgot to use mysql_real_escape_string in part of my webapp. I tested input with following text : Hélène 51°56'12'' http://www.mysite.org/folder 3 functions...
4
by: TechieGrl | last post by:
Prepared statements are new to me and having to do this with a multi- dimensional array is beyond me. Here is the prepared statement block: // Prepare to insert a record into table1...
1
by: lazukars | last post by:
I have done a good amount of research on prepared statements in php. The problem is that I have found various examples on how to select and insert information into a Mysql database. I want to make...
0
by: lazukars | last post by:
I am building some code with msqli prepared statements via. The code will be used for a form that will send data to a MySql database. What I would like to know is how secure are prepared...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.