| |

VerySource

 Forgot password?
 Register
Search
View: 644|Reply: 2

How stored procedures return data sets, please master

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-6 21:30:01
| Show all posts |Read mode
Please the master give an example!
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-29 17:00:01
| Show all posts
Defined in the process
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-8-18 09:45:01
| Show all posts
/// <summary>
        /// Execute stored procedure
        /// </summary>
        /// <param name="storedProcName">stored procedure name</param>
        /// <param name="parameters">stored procedure parameters</param>
        /// <param name="tableName">the name of the table in the DataSet result</param>
        /// <returns>DataSet</returns>
        public static DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DataSet dataSet = new DataSet();
                if (connection.State != ConnectionState.Open)
                    connection.Open();
                SqlDataAdapter sqlDA = new SqlDataAdapter();
                sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
                sqlDA.Fill(dataSet, tableName);
                if (connection.State == ConnectionState.Open)
                    connection.Close();
                return dataSet;
            }
        }
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list