Whats wrong with short code snippit?

  • Thread starter Thread starter Steve1 via DotNetMonster.com
  • Start date Start date
S

Steve1 via DotNetMonster.com

Hi all,

Why is the last line of this code snippit pulling up with an error? Any help
will be appreciated - Thanks, Steve.

string str_SQLLayoutsPound = "SELECT * FROM Layouts ORDER BY Name";
OleDbCommand obj_SQLLayoutsPound = new OleDbCommand( str_SQLLayoutsPound,
obj_SourceConn );
OleDbDataReader obj_ReaderLayoutsPound = obj_SQLLayoutsPound.ExecuteReader();
while( obj_ReaderLayoutsPound.Read())
{
string str_CurrentRecord = obj_ReaderLayoutsPound["Name"].ToString();
string str_SQLLayouts = "SELECT * FROM Layouts WHERE [Name] LIKE '" +
str_CurrentRecord + "' AND Currency = 1" ;
OleDbCommand obj_SQLLayouts = new OleDbCommand( str_SQLLayouts,
obj_DestinationConn );
OleDbDataReader obj_ReaderLayouts = obj_SQLLayouts.ExecuteReader();
if( obj_ReaderLayouts.Read())
{
OleDbDataAdapter obj_AdapterLayouts = new OleDbDataAdapter(
str_SQLLayouts, obj_DestinationConn );
DataSet obj_DatasetLayouts = new DataSet();
obj_AdapterLayouts.Fill( obj_DatasetLayouts, "layouts" );
}
}
 
I took a quick look at it seems that you have an open DataReader
(obj_ReaderLayouts) on the obj_DestinationConn while trying to populate the
obj_DatasetLayouts DataSet using the same connection. The DataReader must be
closed to use the obj_AdapterLayouts DataAdapter on the obj_DestinationConn
Connection.
 
Back
Top