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
 Development Tools
 ASP.NET
 SQL Exception:system error

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-25 : 03:23:23
Hi!

I got the following exception while executing my code.
Exception:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

additional Information: system error

What is the main cause of this?

thanks!

Funnyfrog

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-25 : 04:04:23
Thats an Sql connection error from your .net page to your database.

Add error handling to your code. use

try

{
// Your code goes here
}
catch(exception err)
{
label1.text = err.Message.ToString()
}
finally
{
// Close the database connection
}

Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-25 : 04:10:59
okay i will try that.

Thank you.

Funnyfrog
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-25 : 04:15:49
Glad2help
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-25 : 04:21:04
This is my code for calling the stored procedure:

Public Shared Function GetAttendanceDailyForExport(ByVal dtOperation As Date, Optional ByVal oTransaction As IDbTransaction = Nothing) As DataTable
Dim conn As IDbConnection
Dim bIsOpened As Boolean

conn = CConnectionFactory.CreateServerConnection()
If conn.State <> ConnectionState.Open Then
conn.Open()
bIsOpened = True
End If

Dim dt As DataTable

Try
Dim oDB As New CAttendanceDB(conn)

oDB.SetTransaction(oTransaction)
dt = oDB.GetAttendanceDailyForExport(dtOperation)
Finally
If bIsOpened Then
conn.Close()
End If
End Try

Return dt
End Function

Should i place it here?

Funnyfrog
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-25 : 04:24:54
Oh Oh Its in VB.NET

I migrated from vb.net to c# in 2005, am not sure about error handling in vb.

Do a google search or ask http://forums.asp.net
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2008-09-25 : 04:27:55
it's okay.

Thank you so much!

Funnyfrog
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-25 : 11:08:47
But read up on error handling in vb.net the problem you are having is probably referencing a database value that is probably null or returning an error.

It should have an error line e.g. line 44 or line 12...
Go to Top of Page
   

- Advertisement -