dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersMinu
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » .NET »

While loading i get a problem


Posted Date: 18 Nov 2009      Posted By:: vimal     Member Level: Silver    Member Rank: 0     Points: 1   Responses: 7



System.StackOverflowException was unhandled
Imports System.Math
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Public Class DAL
Dim strCon As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
Public con As New SqlConnection(strCon)

Sub OpenConnection()
If con.State = ConnectionState.Open Then
con.Close()
con.Open()
Else
con.Open()
End If
End Sub
Sub CloseConnection()
con.Close()
End Sub
Function returnDataset(ByVal qry) As DataSet
OpenConnection()
Dim cmd As New SqlCommand(qry, con)
Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
adapter.Fill(ds)
Return ds
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
Function returnDataset1(ByVal qry, ByVal tblNam) As DataSet
OpenConnection()
Dim cmd As New SqlCommand(qry, con)
Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
adapter.Fill(ds, tblNam)
Return ds
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function

Function ExeQuery(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message, "Warning")
Return ex
End Try
End Function
Function ExeQueryWithIdentity(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Dim cmd1 As New SqlCommand("select @@Identity ", con)
PartSaleNoid = cmd1.ExecuteScalar()
' MsgBox(PartSaleNoid)
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message, "Warning")
Return ex
End Try
End Function

Function InsertQuery(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message)
Return ex
End Try
End Function

Function DeleteQuery(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message)
Return ex
End Try
End Function

Function UpdateQuery(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message)
Return ex
End Try
End Function

Function TruncateQuery(ByVal Qry)
Dim statusQry As String
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
statusQry = cmd.ExecuteNonQuery()
Return statusQry
Catch ex As Exception
MessageBox.Show(ex.Message)
Return ex
End Try
End Function
Public Function returnReader(ByVal qry) As SqlDataReader
Dim reader As SqlDataReader
OpenConnection()
Dim cmd As New SqlCommand(qry, con)
Try
reader = cmd.ExecuteReader()
Return reader
Catch ex As Exception
MessageBox.Show(ex.Message)
'Return ex
End Try
End Function
Function returnScalar(ByVal qry)
Dim reader As SqlDataReader
OpenConnection()
Dim cmd As New SqlCommand(qry, con)
Try
Dim id As Object = cmd.ExecuteScalar()
If id Is DBNull.Value Then
Return 1
Else
Return id
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Return ex
End Try
End Function

Function returnSum(ByVal Qry)
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
Dim num As Object = cmd.ExecuteScalar()
If num Is DBNull.Value Then
Return 0
Else
Return Double.Parse(num)
End If
Catch ex As Exception
Return ex
End Try
End Function

Function returnRate(ByVal Qry)
OpenConnection()
Dim cmd As New SqlCommand(Qry, con)
Try
Dim num As Object = cmd.ExecuteScalar()
If num Is DBNull.Value Then
Return 0
Else
Return Double.Parse(num)
End If
Catch ex As Exception
Return ex
End Try
End Function
End Class

these are the warnings coming

Warning 1 Function 'returnDataset' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\SSTransport\SSTransport\DAL.vb 29 5 SSTransport
Warning 2 Function 'returnDataset1' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\SSTransport\SSTransport\DAL.vb 41 5 SSTransport
Warning 3 Function 'returnReader' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\SSTransport\SSTransport\DAL.vb 128 5 SSTransport
Warning 4 Unused local variable: 'reader'. C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\SSTransport\SSTransport\DAL.vb 130 13 SSTransport






Responses

#444003    Author: Mohan      Member Level: Gold      Member Rank: 102     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

Can You post your complete code.

Regards

Mohan Kumar.D



 
#444035    Author: Pannalal Sinha      Member Level: Gold      Member Rank: 179     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

Put all your return statements after try-catch blocks.

Thanks
Panna



 
#444064    Author: Mohan      Member Level: Gold      Member Rank: 102     Date: 18/Nov/2009   Rating: Revenue Score: 0     Points: 0

Function returnDataset(ByVal qry) As DataSet
OpenConnection()
Dim cmd As New SqlCommand(qry, con)
Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
adapter.Fill(ds)
--Return ds --Remove this code from here
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Return ds -- Paste here

End Function

do this for returnDataset1,returnReader fucntions too.

Regards

Mohan Kumar.D






 
#444071    Author: vimal      Member Level: Silver      Member Rank: 0     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

hi
i made the changes .. again getting some error while loading my application.exe



 
#444096    Author: vimal      Member Level: Silver      Member Rank: 0     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

i made the changes .. again getting same error while loading my application.exe


 
#444168    Author: Gaurav Arora        Member Level: Gold      Member Rank: 33     Date: 18/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

What changes you have implemented?



Thanks & regards,
Gaurav Arora - Lead Editor
My Portal - http://msdotnetheaven.com
Nangal Dam - http://mynangal.com
Me in My Own Style



 
#444494    Author: Avinash Mohan      Member Level: Gold      Member Rank: 258     Date: 19/Nov/2009   Rating: 2 out of 52 out of 5     Points: 2

put return ds outside try catch

Thanks and Regards
Avinash Mohan M.R
http://amicably.ning.com



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Exam 70-536
Previous : Query
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.