473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Data reader

Expand|Select|Wrap|Line Numbers
  1. SqlConnection con = new SqlConnection(cn.getcon());
  2.             if (con.State == ConnectionState.Open)
  3.                 con.Close();
  4.             con.Open();
  5.             SqlCommand cmd;
  6.             SqlCommand cmd1;
  7.             SqlDataAdapter dr1;
  8.             SqlDataAdapter dr;  
  9.             cmd = new SqlCommand("select * from sabha00a where s00a0004<='" + A00D0001.Value.ToString("yyyy-MM-dd") + "'",con);
  10.             dr=cmd.ExecuteReader();
  11.             while (dr.Read())
  12.             {
  13.                 cmd1 = new SqlCommand("select * from milka00b where a00b0002=" + dr[0].ToString() + "",con);
  14.                 dr1 = cmd1.ExecuteReader(); 
  15.             }
  16.             con.Close();
  17.  
Exception := Datareader already opened
This error is occured in while loop. for cmd1.ExecuteReader(). I want to use both cmd & cmd1;
Apr 23 '10 #1
1 1425
semomaniz
210 Expert 100+
Please do not double post. your question was answered here

http://bytes.com/topic/c-sharp/answe...a-reader-error
Apr 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lauchlan M | last post by:
Hi In an ASP.NET application, I am doing the following (dtrData is a data reader that has been loaded with data already): if (dtrData.Read()) { lblEDPresentationTime.Text = (DateTime)...
1
by: Mike P | last post by:
I'm using 1 connection to open 3 separate data readers to read data into 3 data grids. However, when I try to use the 2nd reader it says that the first reader must be closed. So I use Close() to...
1
by: mhnazly | last post by:
i'm trying to read data from SQL Server database using data reader and assigned it to a label in my asp.net web application. but when the button is clicked, nothing appears. please help, thanks. ...
1
by: atif | last post by:
hi i hav a prob with data reader. i hav a 2 column in a data table n i hav 2 drop down lists on my page. Now i want to connect my first drop down with the first column of the data table. Though i...
4
by: Ram | last post by:
I am using ADO.Net data reader to retrieve data from main frame. I am getting timestamp which is 26 (yyyy-mm-dd hh- mm-ss.123456) bytes as sqltimestamp data type. I am using data reader to...
6
by: Jim Heavey | last post by:
I am new to SqlServer, have been using Oracle in a prior life. I have written a very simple stored procedure in SQL Server and it (the query) looks like the following... Select AD_ID,...
1
by: simonZ | last post by:
I have data reader(I can't create data adapter, because I'm using command.BeginExecuteReader and EndExecuteReader) What is the best way to save data reader to table inside the data set? Any...
3
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, how do you resolve this problem? i have a public procedure in my DataAccessLayer that gets a SqlDataReader how do i close the reader from inside the DataAccessLayer if I'm returning...
3
by: charvi | last post by:
i hae a ole data reader which contains records extracted from Query.how can i check for end of file in data reader.and i want to know the number of records present in data reader thanks in advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.