
Datareader enables you to view multiple datasets in a single request. This will not only saves time that gets wasted in communicating with the database but also makes your system more scalable and effective.
Follow the codes below for extracting datasets using datareader.
public int ExecuteDML()
{
command.Parameters.Clear();
command.CommandText = this.storedProcedureName;
this.SetParameters(this.storedProcedureName, this.parameterValues);
bool blnConnectionOpenedHere = false;
if(connection.State == ConnectionState.Closed)
{
connection.Open();
blnConnectionOpenedHere = true;
}
SqlDataReader reader = command.ExecuteReader();
reader.Close();
int intRecordsAffected = reader.RecordsAffected;
for(int i = 0; i < command.Parameters.Count; i++)
parameterValues[i] = command.Parameters[i].Value;
if(blnConnectionOpenedHere)
connection.Close();
return intRecordsAffected;
}
Follow the codes below for extracting datasets using datareader.
public int ExecuteDML()
{
command.Parameters.Clear();
command.CommandText = this.storedProcedureName;
this.SetParameters(this.storedProcedureName, this.parameterValues);
bool blnConnectionOpenedHere = false;
if(connection.State == ConnectionState.Closed)
{
connection.Open();
blnConnectionOpenedHere = true;
}
SqlDataReader reader = command.ExecuteReader();
reader.Close();
int intRecordsAffected = reader.RecordsAffected;
for(int i = 0; i < command.Parameters.Count; i++)
parameterValues[i] = command.Parameters[i].Value;
if(blnConnectionOpenedHere)
connection.Close();
return intRecordsAffected;
}
Aspnet Discussion
- - How to Encode-Decode URL
- - Change IE settings using
- - Excel problem
- - Example of Server.Transfe
- - Import Ms Project file


