Solved

return value when connected to a database

Posted on 2004-09-13
1
151 Views
Last Modified: 2010-04-23
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
Comment
Question by:malanois
1 Comment
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 250 total points
ID: 12050573
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
send messages to whatsapp programatically 2 65
VB.NET 2008 Winforms Signing 13 32
VB.net capture  result of a SQL query in variables 3 20
SSRS 2016 Rendering HTML tables 3 29
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question