
Fatal Error, using VB .NET + ADO .NET
I'd deeply appreciate if any one would give me a hand.
I am developing VB. NET App. with following tools
Microsoft Visual Studio .NET Version 7.0.9466
Microsoft .NET Frmework 1.0 Version 1.0.3705
Windows XP Version 5.1.2600 Service Pack 1 Bulid 2600
Database Server : Sysbase Anywhere
I wrote a Class, with a OleDataadapter, datacommand,
Inside, I have a Sub,
input : a SQL Query String,
output : a DataTable
I'd bind the datatable to datagrid , some with populate on the screen.
Since I think that using my own method is more flexible and easiler to
control.
(As many Microsoft provided turtorial is attach a DataAdapter to Each Form,
that would not so efficient)
Now MY PROBLEM IS
I face a occasionally Fatal exception, sometimes is :
#########
An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
##########
or sometimes got other message , something like ExecutionEngine Exception
But the De{*filter*} don't point out exactly which line of code cause that
exception.
sometimes would point to a not related code,
for example :
Text1.text = "0"
This Fatal error is not happen everytime I run the program ,
More offen at Debugging mode
sometimes at Release execution mode.
the following is part of my class file
Public Class clsDB
Const CN_STR = "#####connection string aoo?e###"
WithEvents cnDB As New System.Data.OleDb.OleDbConnection(CN_STR)
WithEvents adDB As New System.Data.OleDb.OleDbDataAdapter()
Dim cmSQL As New OleDb.OleDbCommand()
Public Sub QueryDB(ByVal strQuery As String, ByRef dtUser As
Data.DataTable, Optional ByVal oleTransaction As OleDb.OleDbTransaction =
Nothing)
Dim dtDB As New Data.DataTable()
Try
If (oleTransaction Is Nothing) <> True Then
cmSQL.Connection = oleTransaction.Connection
cmSQL.CommandText = strQuery
adDB.SelectCommand = cmSQL
Else
cmSQL.CommandText = strQuery
cmSQL.Connection = cnDB
adDB.SelectCommand = cmSQL
End If
adDB.Fill(dtUser)
Catch ex As Exception
Throw ex
End Try
End Sub
THANK YOU SO MUCH, INDEED.