Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

return value when connected to a database

I am creating a database program in winforms

I have a program currently going to the machine box for the database.

i will be implementing an online database.

what I need is something like this


If connection to onlinedb = True
then online connection string
Else
offline connection string

is there a way to get a value if I connect properly to a DB.

Thanks
0
malanois
Asked:
malanois
1 Solution
 
DotNetLover_BaanCommented:
yes of course.
If you are using SqlServer, use System.Data.SqlClient namespace
If you are using SqlServer, use System.Data.OleDb namespace

After creating the connection, check the "State" property om that connection
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassStateTopic.asp
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbConnectionClassStateTopic.asp
-Baan
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now