Pregunta

I need to use DataSet ad DataAdapter with the below code but I cannot integrate it. Would you please help me add dataset and dataadapter to this.

DbCommand dbCommand10;
dbCommand10 = db.GetStoredProcCommand("Select_Post_Comment");
db.AddInParameter(dbCommand10, "PostId", DbType.Guid, Post_ID);
//IDataReader dr10 = db.ExecuteReader(dbCommand10);
¿Fue útil?

Solución

// 1. setup command

// 2. add parameters

// 3. pass instance of command to data adapter
var da = new SqlDataAdapter( command );

// 4. create and fill a dataset (executes the command passed to the adapter)
var ds = new DataSet();
da.Fill( ds );

// 5. be sure to dispose command/connection
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top