club_config字段:
bbsname,topicname
reback_config字段:
topicname,topic
现在要根据club_config的a字段删除reback_config里面的记录
我写的句子,但是调试了半天始终不能把表二里面的记录删除掉,
请教高手,不胜感激。String deleteCmd2 = "delete from reback_config where topicname in (select topicname from club_config where bbsname=@bbsname)";
SqlConnection myConnection2 = new SqlConnection(ConfigurationSettings.AppSettings["myweb"]);
SqlCommand myCommand2 = new SqlCommand(deleteCmd2, myConnection2);
myCommand2.Parameters.Add(new SqlParameter("@bbsname", SqlDbType.VarChar, 50));
myCommand2.Parameters["@bbsname"].Value =MyDataGrid.DataKeys[(int)E.Item.ItemIndex].ToString();

解决方案 »

  1.   

    现在要根据club_config的bbsname字段删除reback_config里面的记录
      

  2.   

    直接用下语句在查询分析器中可以吗?如果可以的话,说明你代码有问题,如果不可以的话,说明是你SQL语句有问题。delete from reback_config where topicname in (select topicname from club_config where bbsname=@bbsname)
      

  3.   

    @bbsname在sql语句中将参数用单引号括起来
    "delete from reback_config where topicname in (select topicname from club_config where bbsname='" + @bbsname + "')"
      

  4.   

    可以直接写=@bbsname的,问题依旧,还是删不了。
      

  5.   

    to:rachy(黑色雨)
    程序可以直接写的,因为它是参数。