What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 17383 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > stored procedure calloling in asp .cs page ...
Shanky11

stored procedure calloling in asp .cs page

Replies: 3 | Posted by: Shanky11 on 9/28/2012 | Category: ASP.NET Forums | Views: 288 | Status: [Member] | Points: 10  


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();


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Samirg
Samirg  
Posted on: 9/28/2012 9:59:22 PM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Hariinakoti
Hariinakoti  
Posted on: 9/28/2012 10:01:34 PM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Jayakumars
Jayakumars  
Posted on: 9/28/2012 10:28:19 PM
Level: Bronze | Status: [Member] | Points: 25

hi

did you need after insert retrieve value?

Mark as Answer if its helpful to you

Regards
Email Id: kumaraspcode2009@gmail.com

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

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 1:28:01 AM