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 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
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
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
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
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
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
> 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")"
> 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")"
> Try this. selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' + Families.FirstName) AS FamilyName FROM Families ORDER BY Surname,
FirstName
This returns the same error message.
> Try this. selFamilies.CommandText = "SELECT Families.*, (Families.Surname + ', ' + Families.FirstName) AS FamilyName FROM Families ORDER BY Surname,
FirstName
This returns the same error message.
"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
"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
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?
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?
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.
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.
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")"
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")"
> 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?
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?
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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#),...
|
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...
| |
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...
|
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...
|
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...
|
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!
...
|
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...
|
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,...
| |
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: 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...
|
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: 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...
|
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...
|
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...
| |
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 ...
|
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...
| |