Beispiel #1
0
        public static int do_nonquery(DbCommand input_comm)//带参增删改,例子见方法后面
        {
#if SQLSERVER
                SqlConnection myconn = Hc_db.createConn();
                SqlCommand mycomm =(SqlCommand)input_comm;
#elif MYSQL
                MySqlConnection myconn = Hc_db.createConn();
                MySqlCommand mycomm =(MySqlCommand)input_comm;
#else
            OleDbConnection myconn = Hc_db.createConn();
            OleDbCommand mycomm = (OleDbCommand)input_comm;
#endif
            mycomm.Connection = myconn;
            try
            {
                int c;
                myconn.Open();
                c=mycomm.ExecuteNonQuery();
                myconn.Close();
                //myconn.Dispose();
                return c;
            }
            catch (Exception e1)
            {
                //HttpContext.Current.Response.Write("<script language='javascript' defer>alert('" + e1.ToString() + "');</script>");
                throw (e1);
                //return false;
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        public static DataTable get_datatable(DbCommand input_comm)//带参查询,例子见后面
        {
#if SQLSERVER
            SqlCommand mycomm = (SqlCommand)input_comm;
            mycomm.Connection = Hc_db.createConn();
            SqlDataAdapter myda = new SqlDataAdapter(mycomm);
#elif MYSQL
            MySqlCommand mycomm = (MySqlCommand)input_comm;
            mycomm.Connection = Hc_db.createConn();               
            MySqlDataAdapter myda = new MySqlDataAdapter(mycomm);
#else
            OleDbCommand mycomm = (OleDbCommand)input_comm;
            mycomm.Connection = Hc_db.createConn();
            OleDbDataAdapter myda = new OleDbDataAdapter(mycomm);
#endif
            DataSet myds = new DataSet();
            try
            {
                myda.Fill(myds, "No1");
                return myds.Tables["No1"];
            }
            catch (Exception e1)
            {
                throw (e1);
            }
        }