473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

"Unspecified error" when opening a database

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
Apr 16 '07 #1
0 1759

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ixnay | last post by:
Hello All, I know this issue has be addressed a gazillion times in the past, but none of the offered solutions seem to work for me. I get this error when I attempt to pull down the...
0
by: Sugapablo | last post by:
I have two ASP pages. They basically query a database, and spit out the information as plain text in CSV format. The first has the SQL query hardcoded into it. The second takes a SQL query...
1
by: TJRobertsJob | last post by:
Was wondering if someone could help. Over the last month I've been developing a small database application, using Access 2000, for use in a friends shop. Everything was going well until about a...
5
by: richard | last post by:
I have a licensed MS Office 97 package which I have moved from PC to PC over the years and I have just bought a new machine with XP Pro on it, the latest release. When I install Office, I get the...
2
by: ce | last post by:
Being a newbie regarding serialization and memorystreams, I was trying to see if i could improve page performance (avoiding going to the db on a postback) by saving my serialized business object in...
1
by: aaaaaa | last post by:
running a crystal (v10) reporting app on a virtual web server and getting the "Validation of viewstate MAC failed...." error when opening the crystal viewer. Any help please!!!
6
by: sowencheung | last post by:
I have the following code in the event onbeforeunload if ( typeof executingPostBack != 'undefined' && !executingPostBack ) event.returnValue = ""Warning: Modified data has not been saved.""; ...
3
by: filip.norrgard | last post by:
Hi All! I've been developing an ASP.Net 2.0 web application using the Visual Studio 2005 tools. Currently datagrids on a page are filled with data from a dataset (a .xsd file in the "project")...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.