public static DataTable get_datatable(string s1) { #if SQLSERVER SqlConnection myconn = Hc_db.createConn(); SqlDataAdapter myda = new SqlDataAdapter(s1, myconn); #elif MYSQL MySqlConnection myconn = Hc_db.createConn(); MySqlDataAdapter myda = new MySqlDataAdapter(s1, myconn); #else OleDbConnection myconn = Hc_db.createConn(); OleDbDataAdapter myda = new OleDbDataAdapter(s1, myconn); #endif DataSet myds = new DataSet(); try { myconn.Open(); myda.Fill(myds, "No1"); myconn.Close(); //myconn.Dispose(); return(myds.Tables["No1"]); } catch (Exception e1) { throw (e1); } }
public static bool do_nonquery(string s1) { #if SQLSERVER SqlConnection myconn = Hc_db.createConn(); SqlCommand mycomm = new SqlCommand(s1, myconn); #elif MYSQL MySqlConnection myconn = Hc_db.createConn(); MySqlCommand mycomm = new MySqlCommand(s1, myconn); #else OleDbConnection myconn = Hc_db.createConn(); OleDbCommand mycomm = new OleDbCommand(s1, myconn); #endif try { myconn.Open(); mycomm.ExecuteNonQuery(); myconn.Close(); //myconn.Dispose(); return(true); } catch (Exception e1) { //HttpContext.Current.Response.Write("<script language='javascript' defer>alert('" + e1.ToString() + "');</script>"); throw (e1); //return false; } }
public static DataTable get_datatable_ex(string s1) { OleDbConnection myconn = Hc_db.createConn_ex(); OleDbDataAdapter myda = new OleDbDataAdapter(s1, myconn); DataSet myds = new DataSet(); try { myconn.Open(); myda.Fill(myds, "No1"); myconn.Close(); //myconn.Dispose(); return(myds.Tables["No1"]); } catch (Exception e1) { throw (e1); } }