VB 2017 Community Edition: Testing SQL Server / SQL Server Express to see if they exist

  • Thread starter Thread starter Moondazed
  • Start date Start date
M

Moondazed

Guest
I need to know how to test the existence of either an SQL Server 2014 (or newer) or an SQL Server Express 2014 (or newer) at the beginning of my application or in the Form_Load event of my Login Screen. Allow me to cover the detail of my process. I use SQL Server Express 2014 / 2017 as my local server. I also use SQL Server Standard 2014 as a source to read information into my local SQL Server Express database. The purpose of this is so the user can take the computer offsite (disconnected from the network) and use the application as it was intended (self-standing). A connection at that point to the SQL Server Standard 2014 is not necessary.

* My application is a Windows Form (standalone) app that I have written over the years.

* I store my SQL Server Express name along with the name of the database I am using in a text file (i.e myserv.txt) in my application's folder.

* I store my application users' names and passwords in a table in my database (i.e. MyDB as my database; MySEC as my tablename).

* When I run my application, my login screen is the first screen the user sees. The user keys their username and password and click an OK button.

* Before continuing, I need to know that my SQL Server Standard / SQL Server Express exists given the {computer}\{SQL Server} I have read in from the text file mentioned above. I currently have a sub function that tests to see if the server exists. My sub function is failing via timeout and halts my application. If the application continues and if it does not after a timeout of searching for the server, I produce a screen asking the user to fill in the {computer}\{SQL Server} in a textbox. This is OK; however, I move my solution from one computer to another and the {computer}\{SQL Server} changes.

The bottom line to this is, I need a function that simply returns a boolean value where the function basically asks, "does a SQL Server exist at '{MyComputer\MySQLExpress'". I have seen code online where people have used a dropdown box showing what servers are available; however, many of these reference the older 'sqlserver.sdo' from like 2013. Many of these older pieces do not work in VB 2017 Community Edition. How can I get what I'm after without rewriting a LOT of code that's already in place and without needing additional reference that require extended coding in itself just to know if the SQL Server Express server even exists?

Though I have been using Visual Basic since version 3.0, I am quite sure there are perhaps better methods I could utilize to accomplish what I need. Sadly, I have not spent the probably needed time to research these better methods; therefore, I have stood on the shoulders of some of these geniuses who write articles on the internet to attempt to catch up with more recent technologies.

Thanks for any assistance. It would also be a great help to have code snippets to learn from.

Continue reading...
 

Similar threads

S
Replies
0
Views
63
sva0008
S
D
Replies
0
Views
780
DexterCamarillo
D
D
Replies
0
Views
942
Dante Havenaar
D
Back
Top