示例#1
0
    public static string getValue(string sql)
    {
        string rt = "0";

        try
        {
            SqlConnection con = DBqiye.createConnection();
            con.Open();
            SqlCommand     cmd = new SqlCommand(sql, con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable      dt  = new DataTable();
            sda.Fill(dt);
            con.Close();
            if (dt.Rows.Count > 0)
            {
                rt = dt.Rows[0][0].ToString();
            }
        }
        catch (Exception ex)
        {
            WriteDiskLog("getDataTable:" + ex.Message + ",sql:" + sql);;
        }
        if (Common._sqllog)
        {
            Common.WriteDiskSql(sql);
        }
        return(rt);
    }
示例#2
0
    public static DataSet getData(string sql)
    {
        SqlConnection con = DBqiye.createConnection();

        con.Open();
        SqlCommand     cmd = new SqlCommand(sql, con);
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet        ds  = new DataSet();

        sda.Fill(ds, "dataTable");
        con.Close();
        if (Common._sqllog)
        {
            Common.WriteDiskSql(sql);
        }
        return(ds);
    }
示例#3
0
 public static int getRowsCount(string sql)
 {
     try
     {
         SqlConnection con = DBqiye.createConnection();
         con.Open();
         SqlCommand cmd   = new SqlCommand(sql, con);
         int        count = cmd.ExecuteNonQuery();
         con.Close();
         if (Common._sqllog)
         {
             Common.WriteDiskSql(sql);
         }
         //WriteDiskLog("getRowsCount:sql:" + sql); //return 0;
         return(count);
     }
     catch (Exception ex)
     {
         WriteDiskLog("getRowsCount:" + ex.Message + ",sql:" + sql); return(0);
     }
 }
示例#4
0
 public static int getSelectRowsCount(string sql)
 {
     try
     {
         SqlConnection con = DBqiye.createConnection();
         con.Open();
         SqlCommand     cmd = new SqlCommand(sql, con);
         SqlDataAdapter sda = new SqlDataAdapter(cmd);
         DataTable      dt  = new DataTable();
         sda.Fill(dt);
         con.Close();
         if (Common._sqllog)
         {
             Common.WriteDiskSql(sql);
         }
         return(dt.Rows.Count);
     }
     catch (Exception ex)
     {
         WriteDiskLog("getDataTable:" + ex.Message + ",sql:" + sql); return(-1);
     }
 }