Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / September 2005

Tip: Looking for answers? Try searching our database.

Whats wrong with short code snippit?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve1 - 29 Sep 2005 17:38 GMT
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" );
    }
}
CT - 30 Sep 2005 06:18 GMT
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.

Signature

Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk

> Hi all,
>
[quoted text clipped - 23 lines]
>     }
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.