Return Result from Select Query in stored procedure to a List

前端 未结 8 2043
猫巷女王i
猫巷女王i 2021-01-01 10:10

I\'m writing a stored procedure that currently contains only a SELECT query. It will be expanded to do a number of other things, which is why it has to be a sto

8条回答
  •  天涯浪人
    2021-01-01 10:21

    SqlConnection con = new SqlConnection("Data Source=DShp;Initial Catalog=abc;Integrated Security=True");
    SqlDataAdapter da = new SqlDataAdapter("data", con);
    
    da.SelectCommand.CommandType= CommandType.StoredProcedure;
    
    DataSet ds=new DataSet();
    
    da.Fill(ds, "data");
    GridView1.DataSource = ds.Tables["data"];
    GridView1.DataBind();
    

提交回复
热议问题