Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 System.NullReferenceException

Author  Topic 

maydemir
Starting Member

4 Posts

Posted - 2008-09-11 : 03:52:10
Hi all,

i am developing windows service application on .Net 2.0.
this application work on background and data collecting from more 10 devices and write them to SQL Server 2005 database. my application has multi - thread. Threads are concurrent connect to database (write or read) on one connection. the connection open when application started and open until application end. After a while i get following error :

Type : System.NullReferenceException
Message : Object reference not set to an instance of an object.
Source : System.Data
Stack : at System.Data.SqlClient.TdsParser.AddSqlErrorToCollection(SqlErrorCollection& temp, SqlErrorCollection& InputCollection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected)
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadByte()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at MyService.Data.PackageLog.dsPackageLogTableAdapters.PrcDailyPackagesStatusTableAdapter.PrcDailyPackages(Nullable`1 DICId, Nullable`1 Sent, Nullable`1 Receive, Nullable`1 Error)
at MyService.Data.PackageLog.DailyPackagesStatus.SetDailyPackagesStatus(Int32 DICId, Int32 Sent, Int32 Receive, Int32 Error)

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-11 : 04:07:47
This should have been posted in the .net section.

I work with .net web apps, but not windows. ( But they have many similarities) But from what i can see its obvious

Object reference not set to an instance of an object

You have not instantiated your System.Data.SqlClient
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-11 : 04:09:37
Post your full script and we can have a go
Go to Top of Page

maydemir
Starting Member

4 Posts

Posted - 2008-09-11 : 04:20:06
afrika thanks for replying. But myapplication runs well for about 20 - 30 hours. Then i get this error.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-11 : 04:30:19
Do you have a timeout property set ?
Go to Top of Page

maydemir
Starting Member

4 Posts

Posted - 2008-09-11 : 04:44:23
No i am not set ConnectTimeout
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-11 : 05:08:08
Well, I have a asp.net page that takes a while to process large amounts of data and have this set

command.CommandTimeout = 600;

Which is 10 hours. The default is 20mins
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-11 : 06:51:18
Did you try that ?
Go to Top of Page

maydemir
Starting Member

4 Posts

Posted - 2008-09-11 : 07:45:06
i didn't try that
Go to Top of Page
   

- Advertisement -