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

Parameter problem

Using VS'05 I have a label (LabelFileNum) on an aspx page. I want to set
the text of the lable to the last name, which is a field from a table called
Ante_pedigree from an Access Database.

I use the C# code-behind:

OleDbConnection dbConn = null;

OleDbCommand dCmd = null;

string strConn = null;

string strSQL = null;

// Open data connaction to get name info

strConn =
System.Configuration.ConfigurationManager.AppSetti ngs["oledbConnStr"];

dbConn = new OleDbConnection(strConn);

dbConn.Open();

//Initialize label

LabelFileNum.Text = "";

// Get the last

strSQL = "SELECT LastName FROM Ante_Pedigree Where @AnteNum = ?";

dCmd = new OleDbCommand(strSQL, dbConn);

dCmd.Parameters.AddWithValue("@AnteNum", OleDbType.Char).Value = fileid;

LabelFileNum.Text = LabelFileNum.Text + " " +

dCmd.ExecuteScalar().ToString();

I get the error "No value given for one or more required parameters."

Any suggestions ? This similar code worked in asp.net 1.1

Thanks,

Jim
Apr 17 '06 #1
2 1199
I've seen some strange results from lines like:
dCmd.Parameters.AddWithValue("@AnteNum", OleDbType.Char).Value = fileid;
try breaking it into two lines as you are actually trying to accomplish two
tasks:
dCmd.Parameters.AddWithValue("@AnteNum", OleDbType.Char);
dCmd.Parameters["@AnteNum"].Value = fileid;
(or at least I think that's the syntax)

That may help,
Trevor Braun

"Jim McGivney" <mc****@no-spam.sbcglobal.net> wrote in message
news:eD**************@TK2MSFTNGP02.phx.gbl... Using VS'05 I have a label (LabelFileNum) on an aspx page. I want to set
the text of the lable to the last name, which is a field from a table
called Ante_pedigree from an Access Database.

I use the C# code-behind:

OleDbConnection dbConn = null;

OleDbCommand dCmd = null;

string strConn = null;

string strSQL = null;

// Open data connaction to get name info

strConn =
System.Configuration.ConfigurationManager.AppSetti ngs["oledbConnStr"];

dbConn = new OleDbConnection(strConn);

dbConn.Open();

//Initialize label

LabelFileNum.Text = "";

// Get the last

strSQL = "SELECT LastName FROM Ante_Pedigree Where @AnteNum = ?";

dCmd = new OleDbCommand(strSQL, dbConn);

dCmd.Parameters.AddWithValue("@AnteNum", OleDbType.Char).Value = fileid;

LabelFileNum.Text = LabelFileNum.Text + " " +

dCmd.ExecuteScalar().ToString();

I get the error "No value given for one or more required parameters."

Any suggestions ? This similar code worked in asp.net 1.1

Thanks,

Jim

Apr 17 '06 #2
"SELECT LastName FROM Ante_Pedigree Where @AnteNum = ?"

There you are comparing @AnteNum with ? (both seem to be parameters).

Because the ? is already a parameter then the right way should be:

"SELECT LastName FROM Ante_Pedigree Where AnteNum = ?"

This is how it would be with an SQLCommand:

"SELECT LastName FROM Ante_Pedigree Where AnteNum = @AnteNum"

Hope this helps.

Apr 17 '06 #3

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

Similar topics

4
by: Dan | last post by:
I've run into an interesting problem, and seemed to have stumped 3 newsgroups and 2 other forums. For some reason when I try to insert a record into a SQL table that has a Text column, the...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
4
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from...
2
by: Siegfried Weiss | last post by:
Hi guys, i give up finding a solution by reading or by trial & error. Hope, YOU can help me! (Sorry for my rather long posting.) Stroustrup says, that templates could be declared with - type...
8
by: Dave Veeneman | last post by:
Can I pass a method pass one of its out parameters to another method? C# is telling me I can't. Let's say I have two methods, FooManager and FooWorker. FooManager is part of a class that acts as...
0
by: Billie Boy | last post by:
Hi to all. I’m new here and am coming to you from Melbourne Australia. So a big HELLO 2 ALL. Now I am encountering an annoying problem in the SQL builder of the copy of VB.6 that I am using at...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
4
by: =?Utf-8?B?QmlsbEF0V29yaw==?= | last post by:
Hi, We recently converted a 1.1 project to 2.0 and this included a webservice which accepted XML for one of the parameters. Since converting to 2.0 I am getting the following message: --- A...
5
by: Trevisc | last post by:
Happy Thursday Everyone, I am trying to create a parameter that is one long varchar but that will be used in a SQL statement IN function: //string queryString = GetCurrentTitles(); //Below is...
8
by: DanicaDear | last post by:
I have something interesting...looking to see if anyone else has came across this. I have a query with parameter and and the query works beautifully every time. However, when I use the wizard...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.