public int Update_WorkOrder(int OrdersDetailID, int OperatorID, int PlanerID, DateTime ScheduledEndDate, DateTime PlanDate)
            {
                string ConnectionString="server=localhost;uid=sa;pwd=;database=Data";
                SqlConnection myConnection = new SqlConnection(ConnectionString);
                SqlCommand myCommand = new SqlCommand("[Product].[Update_WorkOrder_OrderTechnician]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.Add(new SqlParameter("@OrdersDetailID", SqlDbType.Int));
                myCommand.Parameters["@OrdersDetailID"].Value = OrdersDetailID;
                myCommand.Parameters.Add(new SqlParameter("@OperatorID", SqlDbType.Int));
                myCommand.Parameters["@OperatorID"].Value = OperatorID;
                myCommand.Parameters.Add(new SqlParameter("@PlanerID", SqlDbType.Int));
                myCommand.Parameters["@PlanerID"].Value = PlanerID;
                myCommand.Parameters.Add(new SqlParameter("@ScheduledEndDate", SqlDbType.DateTime));
                myCommand.Parameters["@ScheduledEndDate"].Value = ScheduledEndDate;
                myCommand.Parameters.Add(new SqlParameter("@PlanDate", SqlDbType.DateTime));
                myCommand.Parameters["@PlanDate"].Value = PlanDate;
                myCommand.Parameters.AddWithValue("@RETURN_VALUE", "").Direction = ParameterDirection.ReturnValue;
                int ok = 0;
                try
                { ///打开数据库的连接
                    myConnection.Open();
                }
                catch (Exception ex)
                {
                    throw new Exception("数据库连接失败!", ex);
                }
                try
                { ///执行数据库的存储过程(访问数据库)
                    SqlDataReader OrderDr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
                    ok = (int)myCommand.Parameters["@RETURN_VALUE"].Value;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                }
                return ok;
            }这是个存储过程的

解决方案 »

  1.   


     public int Update_WorkOrder(int OrdersDetailID,string OrdersDetail)
                {
                    string ConnectionString="server=localhost;uid=sa;pwd=;database=Data";
                    SqlConnection myConnection = new SqlConnection(ConnectionString);
                    SqlCommand cmd=myCommand = new SqlCommand("update 表名 set OrdersDetail=@OrdersDetail where OrdersDetailID=@OrdersDetailID", myConnection);
                    myCommand.Parameters.Add(new SqlParameter("@OrdersDetailID", SqlDbType.Int));
                    myCommand.Parameters["@OrdersDetailID"].Value = OrdersDetailID;                myCommand.Parameters.Add(new SqlParameter("@OrdersDetail", SqlDbType.VarChar));
                    myCommand.Parameters["@OrdersDetail"].Value = OrdersDetail;
    try
                    { ///打开数据库的连接
                        myConnection.Open();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("数据库连接失败!", ex);
                    }
                    try
                    { ///执行数据库的存储过程(访问数据库)
                         myCommand.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message, ex);
                    }把上面的 SqlDataReader OrderDr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)换成myCommand.ExecuteNonQuery();
      

  2.   

    你到 bbs.bbs180.com上搜一下吧,那全是实例,