简体   繁体   中英

Retrieve dataset from SQL stored procedure to C# using dataset and datatable?

My stored procedure returns a dataset of 3 columns (emp id,first name and last name).

I need to use ExecuteSql() with the dataset to display the records on a Dialog box using either Java script or jquery.

SqlDataAdapter da = null;
DataSet ds = new DataSet();
using (var conn = new SqlConnection("connectionString"))
{
    using (var cmd = new SqlCommand())
    {
        conn.Open();
        cmd.Connection = conn;

        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        cmd.CommandText = "sp_Name";
        cmd.ExecuteNonQuery();

        da = new SqlDataAdapter(cmd);
        da.Fill(ds);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM