SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Error: Must declare the scalar variable "@UPDATE".


Error: Must declare the scalar variable "@UPDATE".

Author
Message
jiemin2991
jiemin2991
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 29
Hi,

1)How to resolve this problem " Must declare the scalar variable "@UPDATE".



myConnection = db.getConnection();
DataSet ds = new DataSet();
SqlDataAdapter myAdaptor = new SqlDataAdapter();
SqlCommand Cmd = new SqlCommand();

string year = ddl_AcadYear.SelectedValue;
string period = ddl_AcadPeriod.SelectedValue;

string course = gv_refresh.Columns[0].ToString();

//Cmd.Connection = myConnection;
Cmd.Connection = myConnection;
string sql = "@UPDATE StudNumIPP SET NofStud = '" + noOfStud + "', DBI_IT_Track = '" + dbiItTrack + "', DBI_Biz_Track = '" + dbiBizTrack + "' where acadYear = '" + year + "' AND acadPeriod = '" + period + "' AND Course ='" + course + "' ";
Cmd.CommandText = sql;
myConnection.Open();
Cmd.ExecuteNonQuery();
myConnection.Close();


Thanks.
Mahmood.BilalB
Mahmood.BilalB
SSC Eights!
SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)SSC Eights! (809 reputation)

Group: General Forum Members
Points: 809 Visits: 163
I think you are trying to update a table and using @update (which is used for variables) instead of update

use this (i just delate @ infront of UPDATE)

string sql = "UPDATE StudNumIPP SET NofStud = '" + noOfStud + "', DBI_IT_Track = '" + dbiItTrack + "', DBI_Biz_Track = '" + dbiBizTrack + "' where acadYear = '" + year + "' AND acadPeriod = '" + period + "' AND Course ='" + course + "' ";
Mark Eckeard
Mark Eckeard
SSC Veteran
SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)

Group: General Forum Members
Points: 271 Visits: 505
Either that or you need to us the variable outside of the quotes if it holds a dynamic value.

Mark



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search