给你个参考://==============================================================================
  //功能  :   执行指定的SQL语句
  //参数  :   要执行的Sql语句
  //返回值  :  1:执行成功;0:执行失败
//==============================================================================
  public int ExeSql(string Sql)
  {
   SqlConnection myConnection = new SqlConnection(this.ConnectionString);
   SqlCommand myCommand=new SqlCommand(Sql,myConnection); 
   try
   {
    myConnection.Open();
    myCommand.ExecuteNonQuery();
    myCommand.Dispose();
    myConnection.Close();
    return 1;
   }
   catch(SqlException e)
   {
    errMsg = "";
    errMsg += e.Message;
    myConnection.Close();
    return 0;
   }
  }再加上你的SQL语句就可以了。

解决方案 »

  1.   

    忘了一点,你在写SQL语句的时候要注意跟的数据表的数据类型一致,之所以给上面这么一个函数给你参考是我觉得你写的语句太多了。
      

  2.   

    using(SqlConnection conn = new SqlConnection(source))
    {
          try
          {
              conn.Open();            // 向表中添加记录
              string strInsert = "insert into attendINFO values(@usrID, @timeCome, @timeGo)";
              SqlCommand storeCommand = new SqlCommand(strInsert, conn);
              storeCommand.Parameters.Add("@usrID", usrID));
              storeCommand.Parameters.Add("@timeCome", DateTime.Parse("2003/3/21/3/30"));
              storeCommand.Parameters.Add("@timeGo",DateTime.Parse("2003/3/21/4/30")));
              storeCommand.ExecuteNonQuery();
              conn.Close();        }
          catch(SqlException ae)
         {
             System.Console.WriteLine(ae.Message.ToString());
          }
    }