I am using VB.Net 2003 and MS Access database. Sometimes when I open the
database, I got the error "Unspecifie d error"
The application validate users, when it validates users, it reads from a
table in the database. I use connection pooling by opening the database in
Form_Load, then everytime somebody comes in, I open the database and reads
from it to validate the user. I then close the database.
How can I fix this "Unspecifie d error" ?
Thank you.
Function ValidateDemoUse r(ByVal lIndex As Long, ByRef Packet As String,
ByVal sAccount As String, ByRef Connection As SqlClient.SqlCo nnection, ByRef
ConnectionOLE As OleDb.OleDbConn ection, ByRef ConnectionDemo As
SqlClient.SqlCo nnection, ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
As String
Dim sql As String
Dim bDBSuccess As Boolean
Dim cmd As New OleDb.OleDbComm and
Dim da As OleDb.OleDbData Adapter
Dim ds As DataSet
sql = "select * from CUSTOMER where ACCOUNT = '" & sAccount & "'"
With cmd
bSuccess = True
bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
If bDBSuccess Then
.Connection = ConnectionDemoO LE
.CommandText = sql
da = New OleDb.OleDbData Adapter
ds = New DataSet
da.SelectComman d = cmd
da.Fill(ds)
CloseConDemoOLE (ConnectionDemo OLE)
:
Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
If Not ConnectionDemoO LE Is Nothing Then
ConnectionDemoO LE.Close()
ConnectionDemoO LE = Nothing
End If
End Sub
Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As OleDb.OleDbConn ection)
As Boolean
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionDemoO LE = New OleDb.OleDbConn ection
OpenDBDemoOLE = True
With ConnectionDemoO LE
.ConnectionStri ng = g_dbPathDemo
sSub = "2"
.Open() '--error "Unspecifie d error"
sSub = "3"
If .State = ConnectionState .Closed Then
sSub = "4"
CloseConDemoOLE (ConnectionDemo OLE)
sSub = "5"
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
OpenDBDemoOLE = False
swError = New StreamWriter(Ap plication.Start upPath &
"\AQErrorLo g" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
swError.Write(N ow & " OpenDBDemoOLE - error = " & ex.Message
& " sub = " & sSub & vbCrLf)
swError.Close()
swError = Nothing
End Try
End Function
database, I got the error "Unspecifie d error"
The application validate users, when it validates users, it reads from a
table in the database. I use connection pooling by opening the database in
Form_Load, then everytime somebody comes in, I open the database and reads
from it to validate the user. I then close the database.
How can I fix this "Unspecifie d error" ?
Thank you.
Function ValidateDemoUse r(ByVal lIndex As Long, ByRef Packet As String,
ByVal sAccount As String, ByRef Connection As SqlClient.SqlCo nnection, ByRef
ConnectionOLE As OleDb.OleDbConn ection, ByRef ConnectionDemo As
SqlClient.SqlCo nnection, ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
As String
Dim sql As String
Dim bDBSuccess As Boolean
Dim cmd As New OleDb.OleDbComm and
Dim da As OleDb.OleDbData Adapter
Dim ds As DataSet
sql = "select * from CUSTOMER where ACCOUNT = '" & sAccount & "'"
With cmd
bSuccess = True
bDBSuccess = OpenDBDemoOLE(C onnectionDemoOL E)
If bDBSuccess Then
.Connection = ConnectionDemoO LE
.CommandText = sql
da = New OleDb.OleDbData Adapter
ds = New DataSet
da.SelectComman d = cmd
da.Fill(ds)
CloseConDemoOLE (ConnectionDemo OLE)
:
Sub CloseConDemoOLE (ByRef ConnectionDemoO LE As OleDb.OleDbConn ection)
If Not ConnectionDemoO LE Is Nothing Then
ConnectionDemoO LE.Close()
ConnectionDemoO LE = Nothing
End If
End Sub
Function OpenDBDemoOLE(B yRef ConnectionDemoO LE As OleDb.OleDbConn ection)
As Boolean
Dim swError As StreamWriter
Dim sSub As String
Try
sSub = "1"
ConnectionDemoO LE = New OleDb.OleDbConn ection
OpenDBDemoOLE = True
With ConnectionDemoO LE
.ConnectionStri ng = g_dbPathDemo
sSub = "2"
.Open() '--error "Unspecifie d error"
sSub = "3"
If .State = ConnectionState .Closed Then
sSub = "4"
CloseConDemoOLE (ConnectionDemo OLE)
sSub = "5"
OpenDBDemoOLE = False
End If
End With
Catch ex As Exception
OpenDBDemoOLE = False
swError = New StreamWriter(Ap plication.Start upPath &
"\AQErrorLo g" & Date.Now.ToStri ng("MMddyy") & ".txt", True)
swError.Write(N ow & " OpenDBDemoOLE - error = " & ex.Message
& " sub = " & sSub & vbCrLf)
swError.Close()
swError = Nothing
End Try
End Function