473,473 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Invalid attempt to access a file before calling Read()

68 New Member
Hi,

I'm getting the following error when executing the SQL within this line of code.
Originally, I had coded a stored procedure within the code but this brought up the same error.

I've looked for help elsewhere on the net but can't seem to find anything specific to what I need to resolve this. And I need to use MySqlDataReader so that I can use .GetOrdinal to get the positioning of the columns correct.

Anyone else had and resolved this problem?

Expand|Select|Wrap|Line Numbers
  1. public DataTable GetBibtexPaperDetails(string file)
  2.         {
  3.             using (MySqlConnection sqlCon = new MySqlConnection(ConnectionString))
  4.             {
  5.                 sqlCon.Open();
  6.                 MySqlCommand command = sqlCon.CreateCommand();
  7.                 command.CommandType = CommandType.StoredProcedure;
  8.                 command.CommandText = 
  9.                     string.Format(@"SELECT * FROM PROJmb326.Paper p
  10.                       WHERE p.Title LIKE '{0}' OR p.Keywords LIKE '{0}'
  11.                       ORDER BY p.Title ASC", file);
  12.  
  13.                 DataTable ds = new DataTable();
  14.                 using(MySqlDataReader dr = command.ExecuteReader())
  15.                 {
  16.                     while (dr.Read())
  17.                     {
  18.                         ds.Columns.Add();
  19.                         ds.Rows.Add(dr.GetOrdinal("Author1Firstname").ToString());
  20.                         ds.Rows.Add(dr.GetOrdinal("Author1Surname").ToString());
  21.                     }
  22.                 }
  23.                 return ds;
  24.             }
  25.         }
Mar 6 '10 #1
1 1994
ThatThatGuy
449 Recognized Expert Contributor
where's the error?............................................ ..........
Mar 8 '10 #2

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

Similar topics

3
by: Simon Reye | last post by:
Is there a way to force a floating point value to be invalid? I'm reading floating points from a device and every now and then I get an invalid number, but it is too few and far between for me to...
1
by: Bryan Martin | last post by:
Using udp sockets inside a class called by ASP.NET By impersonating you can use a TCP socket from a external class and call it from a ASP.NET page. However, changing the socket type to UDP and...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
2
by: Brent Burkart | last post by:
Below is the error I am receiving. I have checked SQL Profiler and it is receiving the correct query which runs fine in Query Analyzer. Any ideas? Server Error in '/lockinsheet' Application....
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
5
by: Ed L. | last post by:
I have 5 corrupted page headers as evidenced by these errors: ERROR: Invalid page header in block 13947 of ... The corruption is causing numerous queries to abort. First option is to try to...
4
by: Dave | last post by:
I'm using a datareader to get data from an sql table. The line that gives the error is as follow, dtrReceivers.ToString() which gives the error, Invalid attempt to read when no data is...
1
by: sivam.solai | last post by:
Public Function GetTopLevelThreadName(ByVal ThreadID As Integer) As SqlDataReader Sp_Datasql = "WS_Get_TopLevelThreadName" SqlParam = New SqlParameter(0) {} Try SqlParam(0) = New...
4
by: MarkusR | last post by:
If I run the stored proc in the Query Analyzer this works and I get the expected result set back. However when I run it in my application I get a results set of one row but when I try to access the...
3
by: divsTiw | last post by:
I want to populate combo box with data from OracleDataReader , but "Invalid attempt to read when no data is present." is thrown. there are two rows returned , then too why such error. plzzz...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.