Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone tell me what i'm doing wrong

Status
Not open for further replies.

MarcusCarcus

Technical User
May 24, 2008
1
0
0
I'm trying to get this coding to work, I'm new to c# and programming, but I can't seem to get much further than this and this code will not build.

SqlParameter wellName = new SqlParameter("@wellName", SqlDbType.NVarChar, 50, "wellName").Value = Convert.ToString(cmbWellName);
 
Try this:
(i dint try it)

SqlParameter wellName = new SqlParameter("@wellName", SqlDbType.NVarChar, 50, "wellName")

wellName.Value() = Convert.ToString(cmbWellName);
 
parameter.Value = someValue; is a void method [_SetValue(object value) or something like this in the IL]. there for you cannot declare the variable and set the value in the same instruction.
TipGiver's code will work because your first declaring the variable and then setting the value.



Jason Meckley
Programmer
Specialty Bakers, Inc.
 
If you already have a command, and don't need to use this parameter elsewhere, you can also use

Code:
myCommand.Parameters.Add("@wellName", SqlDbType.NVarChar, 50, "wellName").Value = Convert.ToString(cmbWellName);

I've never used the overload with the "source column" parameter but I don't see why it wouldn't work with that in there.

Hope this helps,

Alex

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
You should use it like this
Code:
SqlParameter wellName = new SqlParameter("@wellName", SqlDbType.NVarChar, 50, ParameterDirection.Input, true, 0, 0, "wellName", DataRowVersion.Current, cmbWellName.Value);

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top