Board index » Visual Studio » "Unspecified error" when opening a database
|
NaveenSharma
|
"Unspecified error" when opening a database
Visual Studio229
I am using VB.Net 2003 and MS Access database. Sometimes when I open the database, I got the error "Unspecified 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 "Unspecified error" ? Thank you. Function ValidateDemoUser(ByVal lIndex As Long, ByRef Packet As String, ByVal sAccount As String, ByRef Connection As SqlClient.SqlConnection, ByRef ConnectionOLE As OleDb.OleDbConnection, ByRef ConnectionDemo As SqlClient.SqlConnection, ByRef ConnectionDemoOLE As OleDb.OleDbConnection) As String Dim sql As String Dim bDBSuccess As Boolean Dim cmd As New OleDb.OleDbCommand Dim da As OleDb.OleDbDataAdapter Dim ds As DataSet sql = "select * from CUSTOMER where ACCOUNT = '" & sAccount & "'" With cmd bSuccess = True bDBSuccess = OpenDBDemoOLE(ConnectionDemoOLE) If bDBSuccess Then .Connection = ConnectionDemoOLE .CommandText = sql da = New OleDb.OleDbDataAdapter ds = New DataSet da.SelectCommand = cmd da.Fill(ds) CloseConDemoOLE(ConnectionDemoOLE) : Sub CloseConDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection) If Not ConnectionDemoOLE Is Nothing Then ConnectionDemoOLE.Close() ConnectionDemoOLE = Nothing End If End Sub Function OpenDBDemoOLE(ByRef ConnectionDemoOLE As OleDb.OleDbConnection) As Boolean Dim swError As StreamWriter Dim sSub As String Try sSub = "1" ConnectionDemoOLE = New OleDb.OleDbConnection OpenDBDemoOLE = True With ConnectionDemoOLE .ConnectionString = g_dbPathDemo sSub = "2" .Open() '-->error "Unspecified error" sSub = "3" If .State = ConnectionState.Closed Then sSub = "4" CloseConDemoOLE(ConnectionDemoOLE) sSub = "5" OpenDBDemoOLE = False End If End With Catch ex As Exception OpenDBDemoOLE = False swError = New StreamWriter(Application.StartupPath & "\AQErrorLog" & Date.Now.ToString("MMddyy") & ".txt", True) swError.Write(Now & " OpenDBDemoOLE - error = " & ex.Message & " sub = " & sSub & vbCrLf) swError.Close() swError = Nothing End Try End Function - |
