473,651 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL 'Unknown Error'

I am getting a System.Data.Sql Client.SqlExcep tion with a message string of
'Unknown Error'. Happens occasionally when creating a "new SqlCommand(...) "
while the same command works perfectly happily hundreds of other times. A
side effect is that the connection closes.
..NET version is 1.1, same thing happens on various machines, but seems to
happen more often on slower ones.
Any ideas?
Nov 17 '05 #1
6 2714
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
I am getting a System.Data.Sql Client.SqlExcep tion with a message string of
'Unknown Error'. Happens occasionally when creating a "new
SqlCommand(...) "
while the same command works perfectly happily hundreds of other times. A
side effect is that the connection closes.
.NET version is 1.1, same thing happens on various machines, but seems to
happen more often on slower ones.
Any ideas?

Nov 17 '05 #2
Ignacio

I don't think I need the VB to get the info, I can get it from the debugger.
Actually on closer inspection it is 'ExecuteNonQuer y()' and not 'new
SQLCommand()' causing the error.
Does any of the info here help?
Message "Unknown error."
InnerException: { }System.Excepti on
_COMplusExcepti onCode: -532459699
_HResult: -2146232060
Class: 20
errorClass: 20
Source: ".Net SqlClient Data Provider"

Everything else seems to be either null, zero or empty strings.

Thanks, Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
I am getting a System.Data.Sql Client.SqlExcep tion with a message string of
'Unknown Error'. Happens occasionally when creating a "new
SqlCommand(...) "
while the same command works perfectly happily hundreds of other times. A
side effect is that the connection closes.
.NET version is 1.1, same thing happens on various machines, but seems to
happen more often on slower ones.
Any ideas?


Nov 17 '05 #3
,Ignacio,

I've now got more information on this. One time, the message in my log file
(next to the 'unknown error' was
"SQL error: Line 1: Incorrect syntax near 'DESCUPDATE'."
I have no commands 'DESCUPDATE' but I do have plenty that start with
'UPDATE' and plenty that end with 'DESC'. So the SqlClient is concatenating
the commands.

Hanving looked at the documentation I now see that SqlCommand (etc) is not
thread-safe, but my app is using several threads to collect data from
connected devices and store the data in the database. Is there any way round
this?
I tried making the SqlConnection and SqlCommand static but that just made
things worse.
Do you know if .NET 2.0 has thread-safe versions of these classes?(I am
using .NET 1.1 now)

Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
I am getting a System.Data.Sql Client.SqlExcep tion with a message string of
'Unknown Error'. Happens occasionally when creating a "new
SqlCommand(...) "
while the same command works perfectly happily hundreds of other times. A
side effect is that the connection closes.
.NET version is 1.1, same thing happens on various machines, but seems to
happen more often on slower ones.
Any ideas?


Nov 17 '05 #4
Hi,

If you are creating a new command in each thread ( or in each operation )
you are ok.

are you using SP ?
If not, why don you dump the content of the CommandText when you get an
error?

it may sound that your query is the one with error.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
,Ignacio,

I've now got more information on this. One time, the message in my log
file
(next to the 'unknown error' was
"SQL error: Line 1: Incorrect syntax near 'DESCUPDATE'."
I have no commands 'DESCUPDATE' but I do have plenty that start with
'UPDATE' and plenty that end with 'DESC'. So the SqlClient is
concatenating
the commands.

Hanving looked at the documentation I now see that SqlCommand (etc) is not
thread-safe, but my app is using several threads to collect data from
connected devices and store the data in the database. Is there any way
round
this?
I tried making the SqlConnection and SqlCommand static but that just made
things worse.
Do you know if .NET 2.0 has thread-safe versions of these classes?(I am
using .NET 1.1 now)

Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
>I am getting a System.Data.Sql Client.SqlExcep tion with a message string
>of
> 'Unknown Error'. Happens occasionally when creating a "new
> SqlCommand(...) "
> while the same command works perfectly happily hundreds of other times.
> A
> side effect is that the connection closes.
> .NET version is 1.1, same thing happens on various machines, but seems
> to
> happen more often on slower ones.
> Any ideas?


Nov 17 '05 #5
Hi,

Did you check the Errors colection?

I though the same once, but only when I wrote the below code I found the
error description.

What about the NativeError?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:8D******** *************** ***********@mic rosoft.com...
Ignacio

I don't think I need the VB to get the info, I can get it from the
debugger.
Actually on closer inspection it is 'ExecuteNonQuer y()' and not 'new
SQLCommand()' causing the error.
Does any of the info here help?
Message "Unknown error."
InnerException: { }System.Excepti on
_COMplusExcepti onCode: -532459699
_HResult: -2146232060
Class: 20
errorClass: 20
Source: ".Net SqlClient Data Provider"

Everything else seems to be either null, zero or empty strings.

Thanks, Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
>I am getting a System.Data.Sql Client.SqlExcep tion with a message string
>of
> 'Unknown Error'. Happens occasionally when creating a "new
> SqlCommand(...) "
> while the same command works perfectly happily hundreds of other times.
> A
> side effect is that the connection closes.
> .NET version is 1.1, same thing happens on various machines, but seems
> to
> happen more often on slower ones.
> Any ideas?


Nov 17 '05 #6
Hi again,

I'm not using threads explicity - but there are a few timers which use the
db connection in their handlers. So, on occasion, the timer handlers may be
trying to connect to the db at the same time.
What is SP?
How do I dump the content of the command text?
What do you mean, "it may sound that your query is the one with error"? As I
mentioned, 99% of the time the (same) commands are processed OK, it's just
now and again the connection gives this error.

Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

If you are creating a new command in each thread ( or in each operation )
you are ok.

are you using SP ?
If not, why don you dump the content of the CommandText when you get an
error?

it may sound that your query is the one with error.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
,Ignacio,

I've now got more information on this. One time, the message in my log
file
(next to the 'unknown error' was
"SQL error: Line 1: Incorrect syntax near 'DESCUPDATE'."
I have no commands 'DESCUPDATE' but I do have plenty that start with
'UPDATE' and plenty that end with 'DESC'. So the SqlClient is
concatenating
the commands.

Hanving looked at the documentation I now see that SqlCommand (etc) is not
thread-safe, but my app is using several threads to collect data from
connected devices and store the data in the database. Is there any way
round
this?
I tried making the SqlConnection and SqlCommand static but that just made
things worse.
Do you know if .NET 2.0 has thread-safe versions of these classes?(I am
using .NET 1.1 now)

Chris

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Did you check InnerException ?
What about the Errors collection ?

Here is a method which unfortunately is in VB.NET that gives you all the
info from a SqlException:

Sub ShowSQLError(By Val e As SqlCeException)

'Dim errorCollection As SqlCeErrorColle ction = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerExceptio n

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToS tring("X"))
bld.Append("\n Message : " + err.Message)
bld.Append("\n Minor Err.: " + err.NativeError .ToString())
bld.Append("\n Source : " + err.Source)

For Each numPar As Integer In err.NumericErro rParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParame ters
If String.Empty <> errPar Then
bld.Append("\n Err. Par. : " + errPar)
End If
Next
MessageBox.Show (bld.ToString() )
If (Not (inner Is Nothing)) Then
ShowSQLError(CT ype(inner, SqlCeException) )

End If
bld.Remove(0, bld.Length)
Next

End Sub
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"quilkin" <qu*****@discus sions.microsoft .com> wrote in message
news:7C******** *************** ***********@mic rosoft.com...
>I am getting a System.Data.Sql Client.SqlExcep tion with a message string
>of
> 'Unknown Error'. Happens occasionally when creating a "new
> SqlCommand(...) "
> while the same command works perfectly happily hundreds of other times.
> A
> side effect is that the connection closes.
> .NET version is 1.1, same thing happens on various machines, but seems
> to
> happen more often on slower ones.
> Any ideas?


Nov 17 '05 #7

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

Similar topics

0
982
by: Eugen Walcher | last post by:
Hello All, I'm getting this error in my error_log in apache. Can anyone offer any assistance in fixing the problem? I'm using RH 9 with apache 2.0.53 and PHP v4.3.11
0
2926
by: Robert | last post by:
did you solve this problem? It seems to be still present here with py2.3.5. Robert -- From: Manish Jethani <manish.j@gmx.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en
5
20431
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied to the test server it won't work at all. Looks like aspnet_wp is trying to compile it for five seconds, then it stops working what so ever. The system event log gets the following entry: Application popup: aspnet_wp.exe - Application Error : The...
1
1826
by: TARUN | last post by:
Hello All, I am facing problem regarding Atlas. I have install the AtlasSetup.msi in my .NET framework 2.0, and i open the new Atlas Website...... Let me first explain the my senario, I have data grid(5 colunm datagrid) on my Page. It's First Colunm is LinkButton whose text property contain the ID. As i click on the this
7
38002
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific situation, and since my experience with JavaScript is limited, I was not able to adapt the solutions I...
1
4577
by: tactech | last post by:
Hello Can somebody help me and tell me why I can’t change the background color of the second PN2 panel. I get this error about unknown source Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException at test$myFreakingListener.actionPerformed(test.java:34) at java.awt.Button.processActionEvent(Unknown Source) at java.awt.Button.processEvent(Unknown Source)
1
7772
by: Valli | last post by:
Hi, I have an issue with the content page('default.aspx') while executing the asp.net project. I am getting the error 1. unknown server tag 'asp.Scriptmanager' 2. unknown server tag 'asp.collapsiblepanelextender' 3. unknown server tag 'asp.UpdatePanel Why I am getting this error.? What should be done to fix it.
3
2618
by: Saša Bistrović | last post by:
Saša Bistrović Antuna Mihanvića 13 40000 Čakovec Croatia sasa.bistrovic@ck.t-com.hr FPC: Exception : Unknown Run-Time error : 210 Hi, I'm Saša from Croatia.
2
7384
by: Calvin Cheng | last post by:
Hi, I am attempting to convert a bunch of .txt files into html using the docutils package. It works for most of the txt files except for the index.txt file which gives 2 errors: (1) <Error/3Unknown Directive type "toctree" (2) (ERROR/3) Unknown interpreted text role "ref".
1
3290
by: Gramma2005 | last post by:
I am trying to connect to an access db through php on Windows Server 2003 running XAMPP. The code I am using has worked before on another access db on this server so I am not sure what is causing the error. Here is my code: # First establish the connection $conn = new COM('ADODB.Connection') or exit('Cannot start ADO'); $result = new COM('ADODB.Recordset') or exit('Coult not make rs'); $db =...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2699
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 we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.