Hi all,
I'm quit new to VB.net and I'm trying to make an application.
It run quit well in VS2010 (debug), but when I "Run Code Analysis on <application> I get a lot of messages:
Warning 1 CA2000 : Microsoft.Reliability : In method 'InputForm.BulkDb(String)', object 'SQLconnect' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'SQLconnect' before all references to it are out of scope. C:\SMAExec\PV2SQLDB\PV2SQLDB\InputForm.vb 927 PV2SQLDB
I was searching for this error and you have to dispose the method, but whatever I do the meesge still occurs.
This is a part of my code:
Public Sub BulkDb(ByVal FullSqlFile As String)
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLite.SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & ApplicPath + DatabaseName & ";"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
'Reads the SQL input file and execute commands
Dim objReader As New System.IO.StreamReader(FullSqlFile)
Dim TextLine As String
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SQLcommand.CommandText = TextLine
SQLcommand.ExecuteNonQuery()
Loop
objReader.Close()
SQLcommand.Dispose()
SQLconnect.Close()
SQLconnect.Dispose()
End Sub
As you can see i'm disposing SQLcommand as well as SQLconnect but it doesn't help.
I'm using also .NET4.
Anyone ideas??
I'm quit new to VB.net and I'm trying to make an application.
It run quit well in VS2010 (debug), but when I "Run Code Analysis on <application> I get a lot of messages:
Warning 1 CA2000 : Microsoft.Reliability : In method 'InputForm.BulkDb(String)', object 'SQLconnect' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'SQLconnect' before all references to it are out of scope. C:\SMAExec\PV2SQLDB\PV2SQLDB\InputForm.vb 927 PV2SQLDB
I was searching for this error and you have to dispose the method, but whatever I do the meesge still occurs.
This is a part of my code:
Public Sub BulkDb(ByVal FullSqlFile As String)
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLite.SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & ApplicPath + DatabaseName & ";"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
'Reads the SQL input file and execute commands
Dim objReader As New System.IO.StreamReader(FullSqlFile)
Dim TextLine As String
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SQLcommand.CommandText = TextLine
SQLcommand.ExecuteNonQuery()
Loop
objReader.Close()
SQLcommand.Dispose()
SQLconnect.Close()
SQLconnect.Dispose()
End Sub
As you can see i'm disposing SQLcommand as well as SQLconnect but it doesn't help.
I'm using also .NET4.
Anyone ideas??