string strSql = " DECLARE @userID int ";
strSql+=" set @userID="+userID.ToString();
strSql+=" DELETE FROM Accounts_RolePermissions WHERE userID=@userID";
strSql+=" DELETE FROM com_info WHERE comID=@userID ";strSql+=" declare @i int,@s bigint set @i=1";
strSql+=" while(@i=1) ";
strSql+=" begin ";
strSql+=" select @s=max(jobID) ";
strSql+=" from com_job";
strSql+=" where userID=@userID";
strSql+=" if(@s is null) begin set @i=0 end ";
strSql+=" else begin";
strSql+=" DELETE FROM person_Job_Collection WHERE JobCollection_jobID =@s ";strSql+=" DELETE FROM com_job WHERE jobID = @s ";
strSql+=" set @s=null end end";strSql+=" DELETE FROM com_job WHERE userID=@userID";
下面的怎么写?
SqlConnection MyConn = new SqlConnection(ConnectionString);SqlCommand myComm = new SqlCommand(strSql,MyConn);我试了用SqlCommand和SqlDataAdapter都不行
望高手指点!!
说明不用存储过程,用的话很好解决。
strSql+=" set @userID="+userID.ToString();
strSql+=" DELETE FROM Accounts_RolePermissions WHERE userID=@userID";
strSql+=" DELETE FROM com_info WHERE comID=@userID ";strSql+=" declare @i int,@s bigint set @i=1";
strSql+=" while(@i=1) ";
strSql+=" begin ";
strSql+=" select @s=max(jobID) ";
strSql+=" from com_job";
strSql+=" where userID=@userID";
strSql+=" if(@s is null) begin set @i=0 end ";
strSql+=" else begin";
strSql+=" DELETE FROM person_Job_Collection WHERE JobCollection_jobID =@s ";strSql+=" DELETE FROM com_job WHERE jobID = @s ";
strSql+=" set @s=null end end";strSql+=" DELETE FROM com_job WHERE userID=@userID";
下面的怎么写?
SqlConnection MyConn = new SqlConnection(ConnectionString);SqlCommand myComm = new SqlCommand(strSql,MyConn);我试了用SqlCommand和SqlDataAdapter都不行
望高手指点!!
说明不用存储过程,用的话很好解决。
MyConn.Open();
myComm.ExecuteNonQuery();
MyConn.Close();
--------------------------------------------
SqlDataAdapter MyAdapter = new SqlDataAdapter(strSql,MyConn); DataSet objDS = new DataSet();MyAdapter.Fill(objDS);
-=---------------------------------
这都不行?我试了都不行
string strSql = "exec(' DECLARE @userID int ";
strSql+=" set @userID="+userID.ToString();
strSql+=" DELETE FROM Accounts_RolePermissions WHERE userID=@userID";
strSql+=" DELETE FROM com_info WHERE comID=@userID ";strSql+=" declare @i int,@s bigint set @i=1";
strSql+=" while(@i=1) ";
strSql+=" begin ";
strSql+=" select @s=max(jobID) ";
strSql+=" from com_job";
strSql+=" where userID=@userID";
strSql+=" if(@s is null) begin set @i=0 end ";
strSql+=" else begin";
strSql+=" DELETE FROM person_Job_Collection WHERE JobCollection_jobID =@s ";strSql+=" DELETE FROM com_job WHERE jobID = @s ";
strSql+=" set @s=null end end";strSql+=" DELETE FROM com_job WHERE userID=@userID')";试一下