Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Error: Must declare the scalar variable "@UPDATE". Expand / Collapse
Author
Message
Posted Sunday, August 5, 2012 8:57 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, August 6, 2012 11:38 PM
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.
Post #1340330
Posted Sunday, August 5, 2012 9:59 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, September 22, 2014 8:07 PM
Points: 627, Visits: 138
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 + "' ";
Post #1340332
Posted Monday, August 6, 2012 10:44 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 5:24 AM
Points: 128, Visits: 490
Either that or you need to us the variable outside of the quotes if it holds a dynamic value.

Mark



Post #1340754
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse