stored procedure calloling in asp .cs page

Posted by Shanky11 under ASP.NET on 9/28/2012 | Points: 10 | Views : 1239 | Status : [Member] | Replies : 3
i hav a parameter procedure in mysql i have to insert value in table through it .
the scenario is as below
three radio button is there how can i get text of all these button in one procedure
string landline = txtcountry.Text + txtcity1.Text + txtphone.Text;
MySqlConnection con = new MySqlConnection("server=localhost;database=infrainvest;uid=root;pwd=root123");
MySqlCommand cmd = new MySqlCommand("regis", con);
cmd.Parameters.Add("utype", rbtnindividual.Text);// here i hav to pass radio button text on desire selection of user
cmd.Parameters.Add("uname", txtname.Text);
cmd.Parameters.Add("uemail", txtemail.Text);
cmd.Parameters.Add("upwd", txtpassword.Text);
cmd.Parameters.Add("mobile", txtmobile.Text);
cmd.Parameters.Add("landln",landline);
cmd.Parameters.Add("city",ddlcity.Text);
//cmd.Parameters.Add("@message", MySqlDbType.VarChar, 50);
//cmd.Parameters["@message"].Direction = ParameterDirection.Output;
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.ExecuteNonQuery();
//Label2.Text = (string)cmd.Parameters["@message"].Value;
con.Close();




Responses

Posted by: Samirg on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down
The below code will resolve your issue.
Replace the datatype of the parameters to the appropriate type if needed.

MySqlConnection con = new MySqlConnection("server=localhost;database=infrainvest;uid=root;pwd=root123"); 

MySqlCommand cmd = new MySqlCommand("regis", con);

cmd.Parameters.Add("utype", SqlDbType.NVarChar,100);
cmd.Parameters["utype"].Value = rbtnindividual.Text;
cmd.Parameters.Add("uname", SqlDbType.NVarChar, 100);
cmd.Parameters["uname"].Value = txtname.Text;
cmd.Parameters.Add("uemail", SqlDbType.NVarChar, 100);
cmd.Parameters["uemail"].Value = txtemail.Text;
cmd.Parameters.Add("upwd", SqlDbType.NVarChar, 100);
cmd.Parameters["upwd"].Value = txtpassword.Text;
cmd.Parameters.Add("mobile", SqlDbType.NVarChar, 100);
cmd.Parameters["mobile"].Value = txtmobile.Text;
cmd.Parameters.Add("landln", SqlDbType.NVarChar, 100);
cmd.Parameters["landln"].Value = landline;
cmd.Parameters.Add("city", SqlDbType.NVarChar, 100);
cmd.Parameters["city"].Value =ddlcity.Text;

cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
}
finally
{
con.Close();
}


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down
Thanq Samirg.Me also have same doubt.it is helpful to me

Thanks & Regards
Hari

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/28/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

did you need after insert retrieve value?

Mark as Answer if its helpful to you

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response