473,395 Members | 1,956 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,395 software developers and data experts.

sqldatareader instance

Why we are not able to create an instance for Sqldatareader
Jul 17 '07 #1
4 1608
nateraaaa
663 Expert 512MB
Why we are not able to create an instance for Sqldatareader
Please provide more information on the problem you are having. A section of code would also be helpful.

Nathan
Jul 17 '07 #2
Plater
7,872 Expert 4TB
It requires there to be data to be read from:
Expand|Select|Wrap|Line Numbers
  1. SqlCommand cmd= new SqlCommand(SQLCmdText,myDBConnection);
  2. SqlDataReader myreader= cmd.ExecuteReader();
  3.  
Jul 17 '07 #3
Please provide more information on the problem you are having. A section of code would also be helpful.

Nathan

Hi
As we create instance for dataset
dataset ds=new datset();
we are not able to create sqldatareader
sqldatareader dr=new sqldatareader();
Jul 24 '07 #4
Plater
7,872 Expert 4TB
Right, you cannot create an empty dataReader like that, which is why I posed this code:
Expand|Select|Wrap|Line Numbers
  1. SqlCommand cmd= new SqlCommand(SQLCmdText,myDBConnection);
  2. SqlDataReader myreader= cmd.ExecuteReader();
  3.  
Now, you can do this:
Expand|Select|Wrap|Line Numbers
  1. SqlDataReader myreader=null;
  2.  
And then use "myreader" anywhere that it is still in scope, if that helps you.
Jul 24 '07 #5

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

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
4
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data...
6
by: James P. | last post by:
I'm trying to pass a sqlDataReader from a called function to a calling function but got nothing back and a message saying "An unhandled exception of type 'System.NullReferenceException' occurred in...
2
by: Stuart Ferguson | last post by:
I am currently writing my first application in VB.Net and have come accross the following problem, my code is as follows 'Alllocate memory for class objects m_oBusiness = New Validation()...
7
by: Web learner | last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows: The name 'dr' does not exist in the current...
1
by: Tin Gherdanarra | last post by:
I understand that an SqlDataReader instance acts as a cursor to a set of query results. This works fine: while(readerInstance.Read()) { Console.WriteLine("{0} {1} {2}", readerInstance,...
1
by: mastershake | last post by:
I'm trying to make some c#. I have a sqldatareader to get the logical file names from *.BAK files. It works on the default instance but if I add a named instance it fails. It gives me this: ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.