.net with Mysql storeprocedure

Posted by Romiltonfdo under ASP.NET on 11/24/2011 | Points: 10 | Views : 1067 | Status : [Member] | Replies : 1
Hello every one..
Am new for .net funda. am also new for mysql. i have one doubt i was create one simple project with the backend mysql. I was create one update stored procedure but its run successfully both database side and .net code side ..but value did not updated.please help me..
my code is :


CREATE PROCEDURE sunhrm.`sp_upcmpinfo`(
In validcmpId int,
In cmpname varchar(200),
In cmpphone varchar(100),
In cmpAddress1 varchar(400),
In cmpAddress2 varchar(400),
In cmpcity varchar(200),
In cmpstate varchar(200),
In cmpcountry varchar(200),
In cmpfax varchar(200),
In cmpzip varchar(200),
In cmpcmd varchar(200))
BEGIN
Update tblcmpinfo SET
fldcmpname = cmpname
,fldcmpphone = cmpphone
,fldcmpaddress1 = cmpAddress1
,fldcmpaddress2 = cmpAddress2
,fldcmpcity = cmpcity
,fldcmpstate = cmpstate
,fldcmpcountry = cmpcountry
,fldcmpfax = cmpfax
,fldcmpzip = cmpzip
,fldcmpcmd = cmpcmd
WHERE CmpId = validcmpId ;
End;

__________
Code :
con.Open();
cmd = new MySqlCommand("sp_upcmpinfo", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@cmpId", lblcmpid.Text);
cmd.Parameters["@cmpId"].Direction = ParameterDirection.InputOutput;
cmd.Parameters.AddWithValue("@cmpname", txtcompany.Text);
cmd.Parameters.AddWithValue("@cmpphone", txtphone.Text);
cmd.Parameters.AddWithValue("@cmpAddress1", txtAddress1.Text);
cmd.Parameters.AddWithValue("@cmpAddress2", txtAddress2.Text);
cmd.Parameters.AddWithValue("@cmpcity", txtCity.Text);
cmd.Parameters.AddWithValue("@cmpstate", ddlState.SelectedItem.Text);
cmd.Parameters.AddWithValue("@cmpcountry", ddlCountry.SelectedItem.Text);
cmd.Parameters.AddWithValue("@cmpfax", txtfax.Text);
cmd.Parameters.AddWithValue("@cmpzip", txtZip.Text);
cmd.Parameters.AddWithValue("@cmpcmd", txtcmd.Text);
cmd.ExecuteNonQuery();


please help me its very urgent




Responses

Posted by: Naraayanan on: 2/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Try this way,
Check this link.I think, it may be useful for your task
http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
CREATE PROCEDURE sunhrm.`sp_upcmpinfo`(

@validcmpId int,
@cmpname varchar(200),
@cmpphone varchar(100),
@cmpAddress1 varchar(400),
@cmpAddress2 varchar(400),
@cmpcity varchar(200),
@cmpstate varchar(200),
@cmpcountry varchar(200),
@cmpfax varchar(200),
@cmpzip varchar(200),
@cmpcmd varchar(200))
Update tblcmpinfo SET fldcmpname = @cmpname,fldcmpphone = @cmpphone,fldcmpaddress1 = @cmpAddress1,fldcmpaddress2 = @cmpAddress2
,fldcmpcity = @cmpcity,fldcmpstate = @cmpstate,fldcmpcountry = @cmpcountry,fldcmpfax = @cmpfax,fldcmpzip = @cmpzip,fldcmpcmd = @cmpcmd
WHERE CmpId = @validcmpId ;




Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

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

Login to post response