日期:2014-05-20  浏览次数:20429 次

System.Exception: 将 varchar 值 '5,7,' 转换为数据类型为 int 的列时发生语法错误。怎么解决?
public   void   DeleteId(string   MemberId)
                {
                        string   strSql   =   "delete   Member   where   MemberId   in   ( ' "   +   MemberId   +   " ') ";
                        DbHelperSQL.ExecuteSql(strSql);
                }


public   static   int   ExecuteSql(string   SQLString)
                {
                        using   (SqlConnection   connection   =   new   SqlConnection(connectionString))
                        {
                                using   (SqlCommand   cmd   =   new   SqlCommand(SQLString,   connection))
                                {
                                        try
                                        {
                                                connection.Open();
                                                int   rows   =   cmd.ExecuteNonQuery();
                                                return   rows;
                                        }
                                        catch   (System.Data.SqlClient.SqlException   E)
                                        {
                                                connection.Close();
                                                throw   new   Exception(E.Message);
                                        }
                                }
                        }
                }