cast string to integer?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new to C#, but have c experience. Anyhow I have a web application and
am just trying to get the selected value of a dropdown box in integer form so
I can pass it to a stored procedure, but cast from string to int is not
allowed.
any suggestions?
string s_user;
int i_user;
s_user = this.dr_user.SelectedValue;
i_user=(int)s_user;
 
ok thanks for the reply, just wondering if you know how to set a parameter
being passed to a stored procedure, Think I am close but get the error
denotes a property where a method was expected under the parameter key word.
thanks,
this.da_usrinfo.SelectCommand.Parameters("@User_Id").Value = i_user;
Picho said:
you can also use Int32.Parse(string s)
or C# specific int.Parse(string s)

Picho
 
=?Utf-8?B?UGF1bA==?= said:
ok thanks for the reply, just wondering if you know how to set a
parameter being passed to a stored procedure, Think I am close but get
the error denotes a property where a method was expected under the
parameter key word. thanks,
this.da_usrinfo.SelectCommand.Parameters("@User_Id").Value = i_user;

I havent looked at the reference, but try:
this.da_usrinfo.SelectCommand.Parameters["@User_Id"].Value = i_user;

Its probably a property and not a method.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
got it to work used

this.da_usrinfo.SelectCommand.Parameters[1].Value = i_user;
thanks for the reply.
Chad Z. Hower aka Kudzu said:
=?Utf-8?B?UGF1bA==?= said:
ok thanks for the reply, just wondering if you know how to set a
parameter being passed to a stored procedure, Think I am close but get
the error denotes a property where a method was expected under the
parameter key word. thanks,
this.da_usrinfo.SelectCommand.Parameters("@User_Id").Value = i_user;

I havent looked at the reference, but try:
this.da_usrinfo.SelectCommand.Parameters["@User_Id"].Value = i_user;

Its probably a property and not a method.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Paul,

Basically you can look at the property of the selectcommand in the
property explorer window and it should show you all the parameters
associated with the command. By default, the first parameter (index 0)
is @RETURN_VALUE. Other params get listed below this. So, you and
Hower both are right and both calling mechanism should work fine
although the one suggested by Hower is more fool proof.

--rk
 
Back
Top