mySqlCommand.ExecuteNonQuery()这不是执行SQL语句的吗?怎么能够去掉

解决方案 »

  1.   

    ExecuteNonQuery()不能去掉,去掉了就不执行数据库操作了
      

  2.   

    catch the exception to see the detailed error messages try
    {
    myConnection.Open();
    SqlCommand mySqlCommand=new SqlCommand(strSQL,myConnection);
    mySqlCommand.ExecuteNonQuery();//关键在这里出问题
    Label1.Text="注册成功";
    }
    catch (Exception ex)
    {

    Label1.Text= ex.Message;
    if (ex.InnerException != null)
    Label1.Text += ex.InnerException.Message; }
    finally
    {
    myConnection.Close();
    }
    also, use string concatenation to form SQL is susceptible to SQL injection attack, use Parameter approach, seehttp://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetch12.asp?frame=true
      

  3.   

    显示出错信息Label1.Text= ex.Message;