/// <summary> /// 执行一条sql语句,回复留言 /// </summary> /// <param name="sql"></param> /// <param name="id"></param> /// <param name="huifu">回复内容</param> /// <returns>返回受影响的行数</returns> public static int PlyExecSql(string sql, int ID, string huifu) { DBSql dbObj = new DBSql(); int i = 0; SqlConnection myConn = dbObj.GetConnection(); SqlCommand myCmd = new SqlCommand(sql, myConn); myConn.Open(); try { myCmd.Parameters.Add("@ID", SqlDbType.Int).Value = ID; myCmd.Parameters.Add("@huifu", SqlDbType.VarChar).Value = huifu; i = myCmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { myCmd.Dispose(); myConn.Close(); } return(i); }
/// <summary> /// 获取单个留言的信息 /// </summary> /// <param name="sql">sql语句</param> /// <param name="M_Table">表名</param> /// <returns></returns> public static DataSet GetMessOnes(string sql, string M_Table) { DBSql dbObj = new DBSql(); SqlConnection myConn = dbObj.GetConnection(); SqlCommand myCmd = new SqlCommand(sql, myConn); myConn.Open(); try { myCmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } finally { myCmd.Dispose(); myConn.Close(); } SqlDataAdapter da = new SqlDataAdapter(myCmd); DataSet ds = new DataSet(); ds.Clear(); da.Fill(ds, M_Table); return(ds); }
public static int AddExecSql(string sql, string name, string datetime, string L_content) { DBSql dbObj = new DBSql(); int i = 0; SqlConnection myConn = dbObj.GetConnection(); SqlCommand myCmd = new SqlCommand(sql, myConn); myConn.Open(); try { myCmd.Parameters.Add("@name", SqlDbType.VarChar).Value = name; myCmd.Parameters.Add("@datetime", SqlDbType.DateTime).Value = datetime; myCmd.Parameters.Add("@L_content", SqlDbType.Text).Value = L_content; i = myCmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { myCmd.Dispose(); myConn.Close(); } return(i); }