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.
Author |
Topic |
leojordao
Starting Member
4 Posts |
Posted - 2006-10-27 : 13:09:19
|
Hello all,I have a problem in my WebApplication. The following error occures:System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.This error occures also occasionaly on other Usercontrols, in which the SQLServer is accessed.I can not reproduce the error. Sometimes it works and sometimes not, with the same data in the webform. Other Applications with the same basic Architecture do nothave this problem.I’m working with Stored Procedures, but not using nvarchar types, just varchar less them 4000.The Application runs on the Webserver with Windows2000AdvancedServer installed and The Database on a Databaseserver also with Windows2000AdvancedServerinstalled and SqlServer2000.There is one part of the code where the error occur . Exactly in the line “Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)”Public Function GetUsuario(ByVal Matricula As String) As Cl_Usuario Dim bd As SqlConnection Try bd = bd_Principal.CriaConexao() Dim sql As New StringBuilder() sql.Append("select U.Matricula,Nome,Ramal,Cgc, codTipoAcesso from Usuarios U ") sql.Append(" inner join Acesso A on u.Matricula = A.Matricula ") sql.Append("where U.Matricula = @Matricula ") Dim paramMatricula As New SqlParameter("@Matricula", SqlDbType.VarChar, 7) Dim myCommand As New SqlCommand(sql.ToString, bd) paramMatricula.Value = Matricula myCommand.Parameters.Add(paramMatricula) If bd.State = ConnectionState.Closed Then bd.Open() End If Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) Dim usuario As New Cl_Usuario() If dr.Read Then usuario.Nome = dr("Nome") usuario.Matricula = dr("Matricula") usuario.Cgc = dr("Cgc") usuario.Ramal = dr("Ramal") usuario.IdPerfil = CType(dr("codTipoAcesso"), Integer) dr.Close() End If Return usuario Catch e As SqlException Debug.WriteLine(e.Message) Debug.WriteLine(e.Number) Debug.WriteLine(e.StackTrace) Throw New Bd_Usuario_Ex(e) Finally If Not IsNothing(bd) Then If bd.State = ConnectionState.Open Then bd.Close() End If End If End TryEnd FunctionThanks in advance for your help. |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-27 : 17:11:26
|
I don't know if this is the reason for your problem, but you must move the dr.Close() outside the If, otherwise the reader will stay open if you execute and get no rows. |
 |
|
leojordao
Starting Member
4 Posts |
Posted - 2006-10-30 : 14:36:42
|
Hi,Thanks for your help.I moved the command “de.close()” like you indicated, but it not solved my problem.it follows below other part of code where the problem occur. Exactly in the line “Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)” Public Function getPerfil(ByVal codTipoAcesso As Integer, ByVal matricula As String) As CL_TipoAcesso Dim myConex As SqlConnection Try Dim bd As New bd_Principal() myConex = bd.CriaConexao Dim sql As New StringBuilder() sql.Append(" select u.Matricula, P.codTipoAcesso, N.Descricao ") sql.Append(" ,Nome,Ramal,Cgc ") sql.Append(" from Usuarios u inner join Acesso P on u.Matricula = p.Matricula ") sql.Append(" inner join TipoAcesso N on p.codTipoAcesso = N.codTipoAcesso ") sql.Append(" Where P.codTipoAcesso = @id ") sql.Append(" and u.Matricula = @Matricula ") Dim paramId As New SqlParameter("@id", codTipoAcesso) Dim paramMatricula As New SqlParameter("@Matricula", matricula) Dim myCommand As New SqlCommand(sql.ToString, myConex) myCommand.Parameters.Add(paramId) myCommand.Parameters.Add(paramMatricula) If myConex.State = ConnectionState.Closed Then myConex.Open() End If Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) Dim TpAcasso As New CL_TipoAcesso() If dr.Read Then TpAcasso.ID = CType(dr("codTipoAcesso"), Integer) TpAcasso.Descricao = CType(dr("Descricao"), String) Else Throw New Ex_PerfilInexistenteException() End If Return TpAcasso Catch ex As Ex_PerfilInexistenteException Debug.WriteLine(ex.Message) Throw ex Catch ex As SqlException Debug.WriteLine(ex.Number) Debug.WriteLine(ex.Message) Throw New Ex_Genericas(ex) Catch ex As Exception Debug.WriteLine(ex.Message) Throw ex Finally If Not IsNothing(myConex) Then If myConex.State = ConnectionState.Open Then myConex.Close() End If End If End Try End FunctionThanks a lot |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-30 : 17:07:24
|
I don't see a problem, I'd say you should try running SQL Server Profiler to see if you can find out more about the error.The SqlException has an Errors collection property. Write some code or use the debugger to have a look at the error/s in that collection, they may give you more specific info about the error on the SQL Server. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-10-31 : 13:16:48
|
try removingIf bd.State = ConnectionState.Closed Thenbd.Open()End Ifdatareader opens the connection itself so you don't need to open it by handand if the connection pool is full this error might occur.Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
leojordao
Starting Member
4 Posts |
Posted - 2006-10-31 : 14:44:21
|
Hi spirit1,i tried your suggestion, but the datareader don't open the connection itself.Maybe i need check the connections to leave the connections pooli'm trying yet.thanks for your help. |
 |
|
leojordao
Starting Member
4 Posts |
Posted - 2006-11-09 : 15:16:58
|
Hi,there is the debug output on error occur.Auto-attach to process '[2112] aspnet_wp.exe' on machine 'PE7466ET027' succeeded.'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.directoryservices\1.0.3300.0__b03f5f7f11d50a3a\system.directoryservices.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.messaging\1.0.3300.0__b03f5f7f11d50a3a\system.messaging.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.serviceprocess\1.0.3300.0__b03f5f7f11d50a3a\system.serviceprocess.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.data\1.0.3300.0__b77a5c561934e089\system.data.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.web\1.0.3300.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.thunk.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.web.regularexpressions\1.0.3300.0__b03f5f7f11d50a3a\system.web.regularexpressions.dll', No symbols loaded.'DefaultDomain': Loaded 'c:\windows\assembly\gac\system.xml\1.0.3300.0__b77a5c561934e089\system.xml.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.web\1.0.3300.0__b03f5f7f11d50a3a\system.web.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.data\1.0.3300.0__b77a5c561934e089\system.data.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.enterpriseservices\1.0.3300.0__b03f5f7f11d50a3a\system.enterpriseservices.thunk.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.web.regularexpressions\1.0.3300.0__b03f5f7f11d50a3a\system.web.regularexpressions.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.xml\1.0.3300.0__b77a5c561934e089\system.xml.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.directoryservices\1.0.3300.0__b03f5f7f11d50a3a\system.directoryservices.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system\1.0.3300.0__b77a5c561934e089\system.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.3300.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.web.services\1.0.3300.0__b03f5f7f11d50a3a\system.web.services.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\assembly\dl2\9741e92b\69d1649b_3ee1c401\microsoft.applicationblocks.data.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\assembly\dl2\6d043baa\4a535cd5_3304c701\bilhetador.dll', Symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\assembly\dl2\af940fac\c4637b88_7529c501\cef_maskedtextbox.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\assembly\dl2\d960bf21\0bd75fde_a388c501\messagebox.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.messaging\1.0.3300.0__b03f5f7f11d50a3a\system.messaging.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.serviceprocess\1.0.3300.0__b03f5f7f11d50a3a\system.serviceprocess.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\n95-yb6c.dll', Symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\microsoft.visualbasic\7.0.3300.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\krulcsmf.dll', Symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\dofwg1d2.dll', Symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\eworld.ui\1.9.0.0__24d65337282035f2\eworld.ui.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\assembly\gac\system.design\1.0.3300.0__b03f5f7f11d50a3a\system.design.dll', No symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\djvnixg-.dll', Symbols loaded.'/LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\temporary asp.net files\sistemas_dotnet_bilhetador\674da8bf\d8817967\4t-cvvcl.dll', Symbols loaded.A severe error occurred on the current command. The results, if any, should be discarded.0A severe error occurred on the current command. The results, if any, should be discarded.0The program '[2112] aspnet_wp.exe: DefaultDomain' has exited with code 0 (0x0).The program '[2112] aspnet_wp.exe: /LM/w3svc/1/root/Sistemas/DotNet/Bilhetador-10-128075756187103272' has exited with code 0 (0x0).Thanks a lot |
 |
|
|
|
|
|
|