473,394 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL 'Unknown Error'

I am getting a System.Data.SqlClient.SqlException 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 2701
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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
I am getting a System.Data.SqlClient.SqlException 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 'ExecuteNonQuery()' and not 'new
SQLCommand()' causing the error.
Does any of the info here help?
Message "Unknown error."
InnerException: { }System.Exception
_COMplusExceptionCode: -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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
I am getting a System.Data.SqlClient.SqlException 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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
I am getting a System.Data.SqlClient.SqlException 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*****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
>I am getting a System.Data.SqlClient.SqlException 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*****@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.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 'ExecuteNonQuery()' and not 'new
SQLCommand()' causing the error.
Does any of the info here help?
Message "Unknown error."
InnerException: { }System.Exception
_COMplusExceptionCode: -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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
>I am getting a System.Data.SqlClient.SqlException 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*****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.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(ByVal e As SqlCeException)

'Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As StringBuilder = New StringBuilder

Dim inner As Exception = e.InnerException

For Each err As SqlCeError In e.Errors
bld.Append("\n Error Code: " + err.HResult.ToString("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.NumericErrorParameters
If 0 <> numPar Then
bld.Append("\n Num. Par. : " + numPar)
End If
Next

For Each errPar As String In err.ErrorParameters
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(CType(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*****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
>I am getting a System.Data.SqlClient.SqlException 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
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
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;...
5
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...
1
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...
7
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...
1
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"...
1
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...
3
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
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)...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.