473,670 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cr eateParameter(" @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 9288
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.Cr eateParameter(" @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.Cr eateParameter(" @firstname", adVarChar,
adParamInpu t, 50, peopleSourceRS( "firstname" ))

But this gives the following error on the browser:

Error Type:
ADODB.Comma nd (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.Cr eateParameter(" @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.connect ion")
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.Cr eateParameter(" @firstname", adVarChar,
adParamInpu t, 50, peopleSourceRS( "firstname" ))

But this gives the following error on the browser:

Error Type:
ADODB.Comma nd (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
propertie s, 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.connect ion")
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.Cr eateParameter(" @firstname", adVarChar,
adParamInpu t, 50, peopleSourceRS( "firstname" ))

But this gives the following error on the browser:

Error Type:
ADODB.Comma nd (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
propertie s, 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.connect ion")
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:

updatedFirstNam e = peopleSourceRS( "firstname" )
updatedSurName = peopleSourceRS( "surname")
whereId = peopleSourceRS( "id")

Dim params
params = array(updatedFi rstName, updatedSurName, whereId)

and I execute like so:

peopleUpdate.Ex ecute , array(updatedFi rstName, updatedSurName, whereId),
adExecuteNoReco rds

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/ProcessPeopleFi le.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.Cr eateParameter(" @firstname", adVarChar,
adParamInpu t, 50, peopleSourceRS( "firstname" ))

But this gives the following error on the browser:

Error Type:
ADODB.Comma nd (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
propertie s, 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.connect ion")
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:
updatedFirstNam e = peopleSourceRS( "firstname" )
updatedSurName = peopleSourceRS( "surname")
whereId = peopleSourceRS( "id")

Dim params
params = array(updatedFi rstName, updatedSurName, whereId)

and I execute like so:

peopleUpdate.Ex ecute , array(updatedFi rstName, updatedSurName,
whereId), adExecuteNoReco rds
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(updatedFi rstName, updatedSurName, _
clng(whereId))

peopleUpdate.Ex ecute , params, _
adExecuteNoReco rds + 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/ProcessPeopleFi le.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
2263
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 prepared statements 'remembered' by the server for a while between connections, so that new connections can take advantage of them, or are they really only useful for those pages/requests that are executing a huge amount of DML in a single shot.
0
3005
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 mysql_error(). This occurs even if the statements are closed after each use. >How-To-Repeat: The following program highlights the problem. Just change the connection details to some database. It also assumes there is a table called dummy,
1
3807
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 interface to use mysqli. Most of what the interface does is to simplify getting results in the form of arrays (ordered and associative). Most of the code using the interface used sql queries with placeholders and parameters. For that reason I'd...
0
6240
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 running into this problem, frequently almost everyday. We figured what exactly to do when the problem happens but not the reason or the solution to this.
2
1862
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 prepared statement use on the server ? If I need to create several hundred in each backend, is there a big memory overhead ? What's the time spent by the backend to find one prepared statement into a list of several hundreds of them ? TIA cyril
2
2727
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 querys. (where you only change the parameters) But what if you do only ONE query; will it then be usefull to use prepared statements? Can it actuelly give better performance NOT to use prepared statements in that case? 2) Are there any DISadvantages...
2
3379
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 worked correctly and 1 failed: The one that failed didn't have mysql_real_escape_string and neither did 2 of the ones that worked: in those 2 I used prepared sql statements (PEAR DB package). The other that I used was with...
4
2478
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 $flag_insert = false; $sql_insert = "INSERT IGNORE INTO table1 "; $sql_insert .= "(ID, url)"; $sql_insert .= "VALUES ";
1
2025
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 sure that I am doing this correctly. Could anyone please show post a correct example of how to SELECT data from mysql via prepared statements via php mysqli() functions and how to INSERT data to mysql via prepared statements via php mysqli()...
0
1423
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 statements? If there are any vulnerabilities, what are they?
0
8388
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8907
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8663
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7423
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1799
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.