コード例 #1
0
 /// <summary>
 /// 执行查询语句,返回DataSet
 /// </summary>
 /// <param name="SQLString">查询语句</param>
 /// <returns>DataSet</returns>
 public DataSet Query(string SQLString, params SQLiteParameter[] cmdParms)
 {
     using (var connection = new SQLiteConnection(this.connectionString))
     {
         using (var cmd = new SQLiteCommand())
         {
             this.PrepareCommand(cmd, connection, null, SQLString, cmdParms);
             using (var da = new SQLiteDataAdapter(cmd))
             {
                 try
                 {
                     DataSet ds = new DataSet();
                     da.Fill(ds, "ds");
                     DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);
                     cmd.Parameters.Clear();
                     return(ds);
                 }
                 catch (SQLiteException ex)
                 {
                     throw new Exception(ex.Message);
                 }
                 finally
                 {
                     da.Dispose();
                     cmd.Dispose();
                     connection.Close();
                 }
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 执行查询语句,返回DataSet
        /// </summary>
        /// <param name="SQLString">查询语句</param>
        /// <returns>DataSet</returns>
        public DataSet Query(string SQLString)
        {
            using (var connection = new SQLiteConnection(this.connectionString))
            {
                connection.Open();
                using (var command = new SQLiteDataAdapter(SQLString, connection))
                {
                    try
                    {
                        DataSet ds = new DataSet();

                        command.Fill(ds, "ds");
                        DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);

                        return(ds);
                    }
                    catch (SQLiteException ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    finally
                    {
                        command.Dispose();
                        connection.Close();
                    }
                }
            }
        }
コード例 #3
0
ファイル: DbHelperSQLP.cs プロジェクト: icprog/FS-SMISCloud
        /// <summary>
        /// 执行查询语句,返回DataSet
        /// </summary>
        /// <param name="SQLString">查询语句</param>
        /// <returns>DataSet</returns>
        public DataSet Query(string SQLString, int timeoutseconds, params SqlParameter[] cmdParms)
        {
            using (SqlConnection connection = new SqlConnection(this.connectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandTimeout = timeoutseconds;
                    PrepareCommand(cmd, connection, null, SQLString, cmdParms);
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataSet ds = new DataSet();
                        try
                        {
                            da.Fill(ds, "ds");
                            DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);

                            return(ds);
                        }
                        catch (System.Data.SqlClient.SqlException ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: DbHelperOleDbP.cs プロジェクト: icprog/FS-SMISCloud
 /// <summary>
 /// 执行查询语句,返回DataSet
 /// </summary>
 /// <param name="SQLString">查询语句</param>
 /// <returns>DataSet</returns>
 public DataSet Query(string SQLString, params OleDbParameter[] cmdParms)
 {
     using (OleDbConnection connection = new OleDbConnection(connectionString))
     {
         using (OleDbCommand cmd = new OleDbCommand())
         {
             PrepareCommand(cmd, connection, null, SQLString, cmdParms);
             using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
             {
                 DataSet ds = new DataSet();
                 try
                 {
                     da.Fill(ds, "ds");
                     DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);
                     return(ds);
                 }
                 catch (OleDbException ex)
                 {
                     throw new Exception(ex.Message);
                 }
                 finally
                 {
                     cmd.Dispose();
                     connection.Dispose();
                 }
             }
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// 执行查询语句,返回DataSet
 /// </summary>
 /// <param name="SQLString">查询语句</param>
 /// <returns>DataSet</returns>
 public static DataSet Query(string SQLString)
 {
     using (OleDbConnection connection = new OleDbConnection(connectionString))
     {
         DataSet ds = new DataSet();
         try
         {
             connection.Open();
             using (OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection))
             {
                 command.Fill(ds, "ds");
                 DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);
                 return(ds);
             }
         }
         catch (System.Data.OleDb.OleDbException ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
コード例 #6
0
ファイル: DbHelperSQL.cs プロジェクト: ewin66/FS-SMISCloud
        public static DataSet Query(string SQLString, int Times)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    using (SqlDataAdapter command = new SqlDataAdapter(SQLString, connection))
                    {
                        DataSet ds = new DataSet();
                        connection.Open();

                        command.SelectCommand.CommandTimeout = Times;
                        command.Fill(ds, "ds");
                        DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);
                        return(ds);
                    }
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
コード例 #7
0
ファイル: DbHelperSQL.cs プロジェクト: ewin66/FS-SMISCloud
 /// <summary>
 /// 执行查询语句,返回DataSet
 /// </summary>
 /// <param name="SQLString">查询语句</param>
 /// <returns>DataSet</returns>
 public static DataSet Query(string SQLString, params SqlParameter[] cmdParms)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         using (SqlCommand cmd = new SqlCommand())
         {
             PrepareCommand(cmd, connection, null, SQLString, cmdParms);
             using (SqlDataAdapter da = new SqlDataAdapter(cmd))
             {
                 DataSet ds = new DataSet();
                 try
                 {
                     da.Fill(ds, "ds");
                     DbHelperCommon.AddDataSetTableNames(SQLString, ref ds);
                     return(ds);
                 }
                 catch (SqlException ex)
                 {
                     throw new Exception(ex.Message);
                 }
             }
         }
     }
 }