//SQL Server Class #region public DataSet SqlGet(string sql, string tblName) { SqlConnection conn = new dboClass().SqlStrCon(); SqlDataAdapter daa = new SqlDataAdapter(sql, conn); DataSet dsa = new DataSet(); daa.Fill(dsa, tblName); return(dsa); }
public int SqlExecute(string sql) { int i; SqlConnection conn = new dboClass().SqlStrCon(); SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }
public DataSet SqlGet(string sql, string tblName, SqlParameterCollection parameters) { SqlConnection conn = new dboClass().SqlStrCon(); SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); foreach (SqlParameter param in parameters) { da.SelectCommand.Parameters.AddWithValue(param.ParameterName, param.SqlDbType).Value = param.Value;//นำข้อมุลเข้าbase } da.Fill(ds, tblName); return(ds); }
public int SqlExecute(string sql, SqlParameterCollection parameters) { int i; SqlConnection conn = new dboClass().SqlStrCon(); SqlCommand cmd = new SqlCommand(sql, conn); foreach (SqlParameter param in parameters) { cmd.Parameters.AddWithValue(param.ParameterName, param.SqlDbType).Value = param.Value; } conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }
public DataSet SqlExcSto(string stpName, string tblName, SqlParameterCollection parameters) { SqlConnection conn = new dboClass().SqlStrCon(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = stpName; foreach (SqlParameter param in parameters) { cmd.Parameters.AddWithValue(param.ParameterName, param.SqlDbType).Value = param.Value; } SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, tblName); return(ds); }