日期:2014-05-19  浏览次数:21251 次

找一下错误
public   static   void   login(string   table,string   uid,string   pw,string   email)
{
        SqlConnection   con=DB.createcon();
con.Open();
SqlCommand   cmd=new   SqlCommand( "insert   into   "+table+ "(uid,pw,email)values( ' "+uid+ " ', ' "+pw+ " ', ' "+email+ " ') ");
cmd.ExecuteNonQuery();
                        con.Close();
}

ExecuteNonQuery:   Connection   属性尚未初始化。
cmd.ExecuteNonQuery();

------解决方案--------------------
SqlCommand cmd=new SqlCommand( "insert into "+table+ "(uid,pw,email)values( ' "+uid+ " ', ' "+pw+ " ', ' "+email+ " ') ",con);
cmd.ExecuteNonQuery();