updating data
-
:)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:
-
:)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:
-
:)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:
SqlCommand SpCmd = new SqlCommand("Select * from Table "); this is may be wrong. When CommanType is StoredProcdure, you have to give the stor proc name: though u are setting CommandText later check it out. The culprit i feel is ExecuteNonQuery(). it should have been ExecuteQuery()
rAm i Think, i Wait, i Fast -- Siddartha