views:

678

answers:

1

I am using a dataSet in C#. I have done a direct count for the number of items in the SQL CE database, so I know how many items that I have in the database. There are no deletions in the the database.

I get the following unexplained exception(s) :

A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll

A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll KeyNotFoundException

This manifests where the communication locks with the SQL CE database.

Does anyone know what causes this and how this can be fixed?

I have searched online and am having no luck to any solutions for this :-(

        // List to be created
        List<TableDat> result = null;
        lock (_sqlcn)
        {
            // Assumes that connection is a valid SqlConnection object.
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(orderSQL, _sqlcn);
            try
            {
                // DataSet that will be returned.
                System.Data.DataSet ds = new System.Data.DataSet();
                int count = adapter.Fill(ds, currentIndex, PageSize, "Logs");


                //Iterate through the table and in the List 
                foreach (System.Data.DataRow myDataRow in ds.Tables["Logs"].Rows)
                {
                    if (result == null)
                    {
                        result = new List<TableDat>();
                    }
                    result.Add(
                              new TableDat(
                                  (int)myDataRow[Resources.ID],
                                  (DateTime)myDataRow[Resources.TimeStamp],
                                  (int)myDataRow[Resources.EVENTLOG_SID],
                                  (int)myDataRow[Resources.EVENTLOG_EID])
                              );

                }
                // Set the dataSet object to NULL : No longer needed as the list 
                // has  been populated
                ds = null;
            }

The biggest problem I see is that this stops the SQL CE database working. Soz, I cannot make out what I should do in the exception handling here as I get nothing in my list which means that the caller has no details for the list??

This just manifests itself. I am looking for a solution which can handle the exception and also to know why my database is behaving as such :-(

Stack Trace looks like:

A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
KeyNotFoundException
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A: 

Usually you don't really need to worry about first chance exceptions. They are usually anticipated and handled by the lower level code inside the dll.

There's a decent write-up on first chance exceptions here.

You can also disable these messages in Visual Studio. (For VS 2005... not sure on 2008).

Jason Down
No changes as I have already unset the Redirect all Output Window text to the Immediate Window. Once I get the exception it stops the database access.
Sporty
??? They are exceptions in non-user code, but usually quite serious.
Henk Holterman
Please can you explain this further?? What can cause these?? How can I get rid of them??
Sporty