473,491 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Repost: Error message

I've got a program that collects info from an Access. I'm trying to use the
following select command to select all the information from the "Families"
table and store it in a dataset, plus join the Surname and FirstName fields
to create a new field, FamilyName:

selFamilies.CommandText = "SELECT Families.*, Families.Surname + ', ' +
Families.FirstName AS FamilyName FROM Families ORDER BY Surname, FirstName"

This has been working perfectly a number of times until recently, and now
when I try to run the program, it stops on this line:

adpFamilies.Fill(datSPARK, "Families")

and gives me this error message:

"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll
Additional information: Invalid attempt to NextResult when reader is
closed."

I'm new to the whole database thing, and this message is Greek to me. If I
use this simple select command instead:

selFamilies.CommandText = "SELECT * FROM Families ORDER BY Surname,
FirstName"

the program doesn't give me the error.

I would really appreciate any help anyone can give me.

Thanks
Carolyn
Nov 20 '05 #1
21 1790
Hi,

Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname, FirstName

Ken
-----------------
"Carolyn" <so*****@newsgroups.microsoft.com> wrote in message
news:e%****************@TK2MSFTNGP11.phx.gbl...
I've got a program that collects info from an Access. I'm trying to use the following select command to select all the information from the "Families"
table and store it in a dataset, plus join the Surname and FirstName fields to create a new field, FamilyName:

selFamilies.CommandText = "SELECT Families.*, Families.Surname + ', ' +
Families.FirstName AS FamilyName FROM Families ORDER BY Surname, FirstName"
This has been working perfectly a number of times until recently, and now
when I try to run the program, it stops on this line:

adpFamilies.Fill(datSPARK, "Families")

and gives me this error message:

"An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: Invalid attempt to NextResult when reader is
closed."

I'm new to the whole database thing, and this message is Greek to me. If I use this simple select command instead:

selFamilies.CommandText = "SELECT * FROM Families ORDER BY Surname,
FirstName"

the program doesn't give me the error.

I would really appreciate any help anyone can give me.

Thanks
Carolyn

Nov 20 '05 #2
Hi,

Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname, FirstName

Ken
-----------------
"Carolyn" <so*****@newsgroups.microsoft.com> wrote in message
news:e%****************@TK2MSFTNGP11.phx.gbl...
I've got a program that collects info from an Access. I'm trying to use the following select command to select all the information from the "Families"
table and store it in a dataset, plus join the Surname and FirstName fields to create a new field, FamilyName:

selFamilies.CommandText = "SELECT Families.*, Families.Surname + ', ' +
Families.FirstName AS FamilyName FROM Families ORDER BY Surname, FirstName"
This has been working perfectly a number of times until recently, and now
when I try to run the program, it stops on this line:

adpFamilies.Fill(datSPARK, "Families")

and gives me this error message:

"An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: Invalid attempt to NextResult when reader is
closed."

I'm new to the whole database thing, and this message is Greek to me. If I use this simple select command instead:

selFamilies.CommandText = "SELECT * FROM Families ORDER BY Surname,
FirstName"

the program doesn't give me the error.

I would really appreciate any help anyone can give me.

Thanks
Carolyn

Nov 20 '05 #3
Try this

Try

selFamilies.CommandText ="SELECT Families.Surname, Families.Surname FROM
People ORDER BY Families.Surname, Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least you
will get an error message with a bit more detail.
Regards OHM
Nov 20 '05 #4
Try this

Try

selFamilies.CommandText ="SELECT Families.Surname, Families.Surname FROM
People ORDER BY Families.Surname, Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least you
will get an error message with a bit more detail.
Regards OHM
Nov 20 '05 #5
Exchange people for Families.

Sorry OHM
One Handed Man wrote:
Try this

Try

selFamilies.CommandText ="SELECT Families.Surname,
Families.Surname FROM People ORDER BY Families.Surname,
Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least
you will get an error message with a bit more detail.
Regards OHM

Nov 20 '05 #6
Exchange people for Families.

Sorry OHM
One Handed Man wrote:
Try this

Try

selFamilies.CommandText ="SELECT Families.Surname,
Families.Surname FROM People ORDER BY Families.Surname,
Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least
you will get an error message with a bit more detail.
Regards OHM

Nov 20 '05 #7
> Try

selFamilies.CommandText ="SELECT Families.Surname, Families.Surname FROM People ORDER BY Families.Surname, Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least you
will get an error message with a bit more detail.


Sorry, I don't understand what your select statement was supposed to
accomplish. If I use that statement, no errors are encountered--the adapter
is not having any trouble accessing the FirstName and Surname columns. But
I tried the Catch and got this "explanation":

System.InvalidOperationException: Invalid attempt to NextResult when reader
is closed.
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(ID ataReader dataReader)
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable,
IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at SPARK.frmFamilyInfo.GetFamilies() in C:\Documents and Settings\Owner\My
Documents\Visual Studio Projects\SPARK\Info Boxes\Family Information.vb:line
1511

Line 1511 is the statement "adpFamilies.Fill(datSPARK, "Families")"
Nov 20 '05 #8
> Try

selFamilies.CommandText ="SELECT Families.Surname, Families.Surname FROM People ORDER BY Families.Surname, Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at least you
will get an error message with a bit more detail.


Sorry, I don't understand what your select statement was supposed to
accomplish. If I use that statement, no errors are encountered--the adapter
is not having any trouble accessing the FirstName and Surname columns. But
I tried the Catch and got this "explanation":

System.InvalidOperationException: Invalid attempt to NextResult when reader
is closed.
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(ID ataReader dataReader)
at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject data, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable,
IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at SPARK.frmFamilyInfo.GetFamilies() in C:\Documents and Settings\Owner\My
Documents\Visual Studio Projects\SPARK\Info Boxes\Family Information.vb:line
1511

Line 1511 is the statement "adpFamilies.Fill(datSPARK, "Families")"
Nov 20 '05 #9
> Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname, FirstName


This returns the same error message.
Nov 20 '05 #10
> Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname, FirstName


This returns the same error message.
Nov 20 '05 #11
"Carolyn" <so*****@newsgroups.microsoft.com> schrieb
I've got a program that collects info from an Access. I'm trying to
use the following select command to select all the information from
the "Families" table and store it in a dataset, plus join the Surname
and FirstName fields to create a new field, FamilyName:

selFamilies.CommandText = "SELECT Families.*, Families.Surname + ', '
+ Families.FirstName AS FamilyName FROM Families ORDER BY Surname,
FirstName"
[...]


I read the whole message and I think the question is not specific to VB.NET.
I think you should turn to microsoft.public.dotnet.framework.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #12
"Carolyn" <so*****@newsgroups.microsoft.com> schrieb
I've got a program that collects info from an Access. I'm trying to
use the following select command to select all the information from
the "Families" table and store it in a dataset, plus join the Surname
and FirstName fields to create a new field, FamilyName:

selFamilies.CommandText = "SELECT Families.*, Families.Surname + ', '
+ Families.FirstName AS FamilyName FROM Families ORDER BY Surname,
FirstName"
[...]


I read the whole message and I think the question is not specific to VB.NET.
I think you should turn to microsoft.public.dotnet.framework.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #13
Just another note that may be of help. I tried setting the CommandText
properties in the form design with my original select query, then
right-clicked the data adapter and went to Preview Data. When I fill the
dataset with the selFamilies query, it returns the correct information.
However, when I run the program without readjusting the query in code, I
still encounter the error message. It is obviously gathering the correct
data from the database; is it trying to do something else with the dataset?
Nov 20 '05 #14
Just another note that may be of help. I tried setting the CommandText
properties in the form design with my original select query, then
right-clicked the data adapter and went to Preview Data. When I fill the
dataset with the selFamilies query, it returns the correct information.
However, when I run the program without readjusting the query in code, I
still encounter the error message. It is obviously gathering the correct
data from the database; is it trying to do something else with the dataset?
Nov 20 '05 #15
Hi,

This works with the northwind database. You should check the field
names capitalization counts.
Dim strConn As String

Dim conn As SqlConnection

Dim drCustomer As SqlDataReader

Dim cmd As SqlCommand

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = NorthWind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

cmd = New SqlCommand("Select Customers.*, (Customers.ContactTitle + ', ' +
Customers.ContactName) as FullName from Customers Order by ContactTitle,
ContactName", conn)

conn.Open()

drCustomer = cmd.ExecuteReader

Do While drCustomer.Read

Debug.WriteLine(drCustomer("FullName"))

Loop

conn.Close()

Ken

-------------------------------

"Carolyn" <so*****@newsgroups.microsoft.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname,

FirstName


This returns the same error message.

Nov 20 '05 #16
Hi,

This works with the northwind database. You should check the field
names capitalization counts.
Dim strConn As String

Dim conn As SqlConnection

Dim drCustomer As SqlDataReader

Dim cmd As SqlCommand

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = NorthWind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

cmd = New SqlCommand("Select Customers.*, (Customers.ContactTitle + ', ' +
Customers.ContactName) as FullName from Customers Order by ContactTitle,
ContactName", conn)

conn.Open()

drCustomer = cmd.ExecuteReader

Do While drCustomer.Read

Debug.WriteLine(drCustomer("FullName"))

Loop

conn.Close()

Ken

-------------------------------

"Carolyn" <so*****@newsgroups.microsoft.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Try this.

selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' +
Families.FirstName) AS FamilyName FROM Families ORDER BY Surname,

FirstName


This returns the same error message.

Nov 20 '05 #17
OK,

Well from the diagnostic output, it would appear that the reader has somehow
decided that the connection was closed ( appears ), check the connection
status after the MessageBox.Show statement to determine if that is the case.

If not, it may be that there is some corruption in the data which is causing
the reader to fail. Try creating a new table with say three records in it
which you have manually created and see if the same thing happens.

Failing that you could post your code and DB ( with dummy data ) to this
newsgroup and we can try and help.

OHM


Carolyn wrote:
Try

selFamilies.CommandText ="SELECT Families.Surname,
Families.Surname FROM People ORDER BY Families.Surname,
Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at
least you will get an error message with a bit more detail.


Sorry, I don't understand what your select statement was supposed to
accomplish. If I use that statement, no errors are encountered--the
adapter is not having any trouble accessing the FirstName and Surname
columns. But I tried the Catch and got this "explanation":

System.InvalidOperationException: Invalid attempt to NextResult when
reader is closed.
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(ID ataReader
dataReader) at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject
data, String srcTable, IDataReader dataReader, Int32 startRecord,
Int32 maxRecords, DataColumn parentChapterColumn, Object
parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) at SPARK.frmFamilyInfo.GetFamilies() in C:\Documents and
Settings\Owner\My Documents\Visual Studio Projects\SPARK\Info
Boxes\Family Information.vb:line 1511

Line 1511 is the statement "adpFamilies.Fill(datSPARK, "Families")"

Nov 20 '05 #18
OK,

Well from the diagnostic output, it would appear that the reader has somehow
decided that the connection was closed ( appears ), check the connection
status after the MessageBox.Show statement to determine if that is the case.

If not, it may be that there is some corruption in the data which is causing
the reader to fail. Try creating a new table with say three records in it
which you have manually created and see if the same thing happens.

Failing that you could post your code and DB ( with dummy data ) to this
newsgroup and we can try and help.

OHM


Carolyn wrote:
Try

selFamilies.CommandText ="SELECT Families.Surname,
Families.Surname FROM People ORDER BY Families.Surname,
Families.Surname"

Catch ex as Exception

MessageBox.Show(ex.ToString())

End try

Hopefully this amended Commandtext will do the trick, if not at
least you will get an error message with a bit more detail.


Sorry, I don't understand what your select statement was supposed to
accomplish. If I use that statement, no errors are encountered--the
adapter is not having any trouble accessing the FirstName and Surname
columns. But I tried the Catch and got this "explanation":

System.InvalidOperationException: Invalid attempt to NextResult when
reader is closed.
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(ID ataReader
dataReader) at System.Data.Common.DbDataAdapter.FillFromReader(Ob ject
data, String srcTable, IDataReader dataReader, Int32 startRecord,
Int32 maxRecords, DataColumn parentChapterColumn, Object
parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) at SPARK.frmFamilyInfo.GetFamilies() in C:\Documents and
Settings\Owner\My Documents\Visual Studio Projects\SPARK\Info
Boxes\Family Information.vb:line 1511

Line 1511 is the statement "adpFamilies.Fill(datSPARK, "Families")"

Nov 20 '05 #19
> OK,

Well from the diagnostic output, it would appear that the reader has somehow decided that the connection was closed ( appears ), check the connection
status after the MessageBox.Show statement to determine if that is the

case.

Thanks a lot. This seems to be the case. Now can you tell me why/how the
connection is being closed?
Nov 20 '05 #20
Did you try my suggestions?

///
If not, it may be that there is some corruption in the data which is causing
the reader to fail. Try creating a new table with say three records in it
which you have manually created and see if the same thing happens.

Failing that you could post your code and DB ( with dummy data ) to this
newsgroup and we can try and help.
\\\

OHM

Carolyn wrote:
OK,

Well from the diagnostic output, it would appear that the reader has
somehow decided that the connection was closed ( appears ), check
the connection status after the MessageBox.Show statement to
determine if that is the case.


Thanks a lot. This seems to be the case. Now can you tell me
why/how the connection is being closed?

Nov 20 '05 #21
I think I may have fixed the problem, but I'm still a little confused as to
what caused it. In preparing the project to post, I stripped it down to
just the one form causing the problem, then deleted all the form's code
except what would be necessary for you to examine. In doing so, I found
that the programme works fine if I leave out the SaveInfo subroutine, which
includes an Update call. I may need to start a new post to get some help on
this updating procedure if I can't figure it out. Thanks so much for your
help.

Carolyn

Nov 20 '05 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2220
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
5
1737
by: Joe | last post by:
Please repost answer message did not make it last time Hello, Joe here, wanted to get the 411 on this article. I posted in the FrontPage forum but there is never an answer. So I have come...
1
1680
by: Yannick Turgeon | last post by:
Hello, This is a repost (see under the "dotted" line) from 2 days ago. Hope someone could help. Norton Antivirus 2003 is installed on this computer. Could it cause a problem? Another...
3
1842
by: Adam | last post by:
I've posted about this previously, but failed to receive a satisfactory response, so have included a code sample: I am trying to receive messages from an HTML viewer control in compact.net (c#),...
1
3643
by: JoeS | last post by:
Is there anyway to share a single pch file between projects in VC 7.0? I have 300+ projects each of which creates its own pch. All projects include the exact same header files in the precompiled...
0
2026
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
14
2798
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
2
1856
by: Learning SQL Server | last post by:
Forgive the repost, but this is really troublesome and I hope SOMEONE can shed some light on it. I am trying to update a datarow via in-place editing from a dataset stored in session. When I...
0
1643
by: Ken Powers | last post by:
Hello everyone, Sorry about the repost, my second VB.NET App is done with the exception of this error. I'm getting a strange error when I try to bind a combo box to a Dataset. Here's my code! ...
1
2037
by: lecnac | last post by:
Sorry for the repost. I must have done something wrong when I tried to post my reply (I can't seem to find it). Anyway, I'd really appreciate any help that anyone could provide. My issue is...
0
7112
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
7146
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
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5448
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,...
1
4878
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
4573
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
3084
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
1389
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 ...
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.