Error message

C

Carolyn

I've got a VB.NET program that collects info from an Access database. 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:
System.InvalidOperationException: Invalid attempt to NextResult when reader
is closed.
at System.Data.OleDb.OleDbDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(IDataReader dataReader)
at System.Data.Common.DbDataAdapter.FillFromReader(Object 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"

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?


I would really appreciate any help anyone can give me.

Thanks
Carolyn
 
M

Miha Markic

Hi Carolyn,

What happens if you remove "(Families.Surname + ', ' + Families.FirstName)"
part?
Does other database operations work normally?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top