TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gustavo
NA
1.3k
453.9k
Try / Catch - Not catching error
Mar 5 2010 2:21 AM
Hello:
I thought that if there is an error between the 'try' it would execute the 'catch'? Below is my code and its seems its not catching the error on the TestConnection.Open();
try
{
SqlConnection
TestConnection =
new
SqlConnection
();
TestConnection.ConnectionString =
@"Server=hpw7v64.ggamvpn.gbridge.net;Database=IPDev;User ID=**********;Password=**********;"
;
TestConnection.Open();
//<<<ERROR - If the server is stopped.
//
SqlDataAdapter
TestDataAdapter =
new
SqlDataAdapter
(
"SELECT * FROM [User]"
, TestConnection);
DataSet
TestDataSet =
new
DataSet
();
//
TestDataAdapter.Fill(TestDataSet);
dataGridViewMSSQLHP.DataSource = TestDataSet.Tables[0];
dataGridViewMSSQLHP.Refresh();
}
catch
(
SqlException
SQLExecute)
{
MessageBox
.Show(
"Connection failed...MSSQL HP"
+ SQLExecute,
"Test Connection..."
,
MessageBoxButtons
.OK,
MessageBoxIcon
.Error);
}
Reply
Answers (
7
)
draw random graphical images in c# windows application
Lightweight c# editor not as large an app as visual studio