TechnoSpike
Programmer
Hi! I'm having trouble trying to fill a DataSet with the results of a procedure I wrote. The procedure has 1 parameters and is composed of a select query (select id,text from Users where id=id_passed_by_param). My problem regards using this procedure to fill a DataSet. I was trying to do this:
try{
// create and open a connection object
conn = new SqlConnection(string_conn);
conn.Open();
SqlCommand cmd = new SqlCommand
("Proc", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@id", 1));
SqlDataAdapter da = new SqlDataAdapter(cmd);
// I'm stuck here...what can I do to fill the Dataset?
// normally I would do this:
// DataSet ds = new DataSet();
// da.fill(ds,"TableName");
// but in this case, what can I do?
}
finally
{
if (conn != null){
conn.Close();
}
}
Also I'm not exactly sure how I can execute the procedure...I don't want a DataReader (so I can't use the ExecuteReader()), unless I can somehow convert the data received by the procedure to the DataSet....Any help would be great!
try{
// create and open a connection object
conn = new SqlConnection(string_conn);
conn.Open();
SqlCommand cmd = new SqlCommand
("Proc", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@id", 1));
SqlDataAdapter da = new SqlDataAdapter(cmd);
// I'm stuck here...what can I do to fill the Dataset?
// normally I would do this:
// DataSet ds = new DataSet();
// da.fill(ds,"TableName");
// but in this case, what can I do?
}
finally
{
if (conn != null){
conn.Close();
}
}
Also I'm not exactly sure how I can execute the procedure...I don't want a DataReader (so I can't use the ExecuteReader()), unless I can somehow convert the data received by the procedure to the DataSet....Any help would be great!