473,321 Members | 1,916 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,321 software developers and data experts.

SQLClient Parameter Bug?

bob
Hi,
Is this a bug?
SqlClient Parameters collection
Prior to the following snippet a set of parameters were declared and
added to the parameters collection.
The parameter values I originally assigned using the syntax in the
SECOND line of code.

The code failed on the first line when it was written in the second
line syntax.with

'this Parameter collection does not contain parameter 'pmyID''

So I altered toaddress the parameter directly and the line executes
ok.
given that intellisense allows you to construct the second line syntax
is there a bug here?

thanks
Bob

pmyId.Value = en.Current.ID.ToString(); //This line works
mycmd.Parameters["pmyId"].Value = en.Current.ID.ToString() //This
line fails

Jul 12 '07 #1
2 1424
"bob" <st**************@cutthis.adriley.co.nzwrote in message
news:8b********************************@4ax.com...
pmyId.Value = en.Current.ID.ToString(); //This line works
mycmd.Parameters["pmyId"].Value = en.Current.ID.ToString() //This
line fails
The line that fails should take in the indexer the name of the parameter,
which probably doesn't match the name of the variable that holds it. That
is, you have to use Parameters["@MyId"] instead of Parameters["pmyId"].
Jul 12 '07 #2
bob

Hi Alberto,
Thanks for that.
regards
bob
On Thu, 12 Jul 2007 08:23:17 +0200, "Alberto Poblacion"
<ea******************************@poblacion.orgwro te:
>"bob" <st**************@cutthis.adriley.co.nzwrote in message
news:8b********************************@4ax.com.. .
>pmyId.Value = en.Current.ID.ToString(); //This line works
mycmd.Parameters["pmyId"].Value = en.Current.ID.ToString() //This
line fails

The line that fails should take in the indexer the name of the parameter,
which probably doesn't match the name of the variable that holds it. That
is, you have to use Parameters["@MyId"] instead of Parameters["pmyId"].
Jul 13 '07 #3

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

Similar topics

1
by: Bob of the West | last post by:
Hi, I'm trying to something quite straightforward, populate a datagrid with certain fields after selecting from a dropdownlist. The books I have don't seem to give an example of how to do this (...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
2
by: Patrick Olurotimi Ige | last post by:
I converted the code below from VB.NET to C# cos i have to add it to a C# application!! But i'm getting the error:- System.Data.SqlClient.SqlCommand.Parameters' denotes a 'property' where a...
5
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the...
1
by: BobRoyAce | last post by:
I have a class that has several Subs that do DB things, some of which require the same set of parameters to be passed to a stored procedure. One class has 12 parameters and part of code used to...
1
by: weird0 | last post by:
System.Data.SqlClient.SqlException: An attempt to attach an auto- named database for file "Location" failed. A database with the same name exists, or specified file cannot be opened, or it is...
0
by: danielhamd | last post by:
I am converting a website that uses an Access Database to SQL Server. On one particular SqlDataSource I am having a lot of trouble. Here is the original: <asp:SqlDataSource ID="SqlDataSource1"...
1
by: thithi | last post by:
Please help me " System.Data.SqlClient.SqlException: Prepared statement '(@Name varchar(100),@Describes varchar(100),@Money char(10))Upda' expects parameter @Describes, which was not supplied. at...
7
by: =?Utf-8?B?a19tYW4=?= | last post by:
Hi all, Have a strange problem with SqlClient timeouts. Here is some background: About a month ago I upgrade from SQL 2000 to 2008. Am using Stored Procedures for all the data access. Most of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.