private static int MakeExecNonQuery(string Query)
{
int id = 0;
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand(Query, con);
con.Open();
var rowCount = cmd.ExecuteScalar();
con.Close();
if (rowCount != DBNull.Value)
id = Convert.ToInt32(rowCount);
return id;
}
public static void MakeDataSet(DataSet ds, String strSQL)
{
try
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(strSQL, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
private static List<ColorTable_Master> GetColorTable_Masters()
{
List<ColorTable_Master> ColorTable_Masterlist = new List<ColorTable_Master>();
String cmd = "SELECT * FROM mytable";
DataSet dsColorTable_Master = new DataSet();
DBAction.MakeDataSet(dsColorTable_Master, cmd);
if (dsColorTable_Master.Tables[0].Rows.Count > 0)
{
foreach (DataRow dsrow in dsColorTable_Master.Tables[0].Rows)
{
ColorTable_Master cObj = new ColorTable_Master();
if (dsrow["Id"] != DBNull.Value)
{
cObj._Id = int.Parse(dsrow["Id"].ToString());
}
ColorTable_Masterlist.Add(cObj);
}
}
return ColorTable_Masterlist;
}
{
int id = 0;
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand(Query, con);
con.Open();
var rowCount = cmd.ExecuteScalar();
con.Close();
if (rowCount != DBNull.Value)
id = Convert.ToInt32(rowCount);
return id;
}
public static void MakeDataSet(DataSet ds, String strSQL)
{
try
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(strSQL, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
private static List<ColorTable_Master> GetColorTable_Masters()
{
List<ColorTable_Master> ColorTable_Masterlist = new List<ColorTable_Master>();
String cmd = "SELECT * FROM mytable";
DataSet dsColorTable_Master = new DataSet();
DBAction.MakeDataSet(dsColorTable_Master, cmd);
if (dsColorTable_Master.Tables[0].Rows.Count > 0)
{
foreach (DataRow dsrow in dsColorTable_Master.Tables[0].Rows)
{
ColorTable_Master cObj = new ColorTable_Master();
if (dsrow["Id"] != DBNull.Value)
{
cObj._Id = int.Parse(dsrow["Id"].ToString());
}
ColorTable_Masterlist.Add(cObj);
}
}
return ColorTable_Masterlist;
}