Pinging a database

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
Is there a way to "Ping" a database to constantly check it to see if there are any records in it and write a program to display the number of records it finds? I could write the program if i knew of a way to "Ping" the database.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
To count the records you'll have to connect and issue a SELECT statement anyway so why not just do that?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
As Nothinman says, you're just talking about connecting to the database and issuing a query. Post the details of the database engine and application environment and I'm sure you'll get plenty of ideas.
 

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
Right now im connected to the Access Database through VB.net. I can run an sql statement but I cant figure out how to continuously run the sql statement over and over...kind of like monitoring it
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Are you using VB.Net inside of Access or in a separate application? If it's a separate application you should be able to just use a loop to run your query indefinitely or until some condition is met.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
Couldn't you setup a timer to query every so many seconds (should only take a millisecond to query the DB though) and if it fails the query stop the timer...
 

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
K i have the program set up up and going refreshing every 10 seconds but for some reason at random times it crashes and here is the error:


************** Exception Text **************

System.Data.OleDb.OleDbException: Unspecified error

at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)

at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)

at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)

at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

at System.Data.OleDb.OleDbConnection.Open()

at WrMon.Form1.timer1_Tick(Object sender, EventArgs e)

at System.Windows.Forms.Timer.OnTick(EventArgs e)

at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Any clue as to what it could be? Dio i have it hitting the db to quickly?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Looks like you have some debuggin to do, hard to say what the problem is though since the exception is just "Unspecified Error".
 

BoberFett

Lifer
Oct 9, 1999
37,562
9
81
Are you closing the connection each time or just opening a new one and never releasing? Are you trying to open an already open connection?
 

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
I was opening a connection each run. At the end of each run, its also closing. I think i pretty much got everything working but now I noticed it errors out when someone else is accessing the database because it locks out anybody else from viewing....is there a way to get around this or checking to see if the database is locked and tell it to pause for a couple seconds.

Thanks for replies all