hi! guyz!!! i have a question here..Currently, i have this code below
as you can see i dont have a way to check if there's an error like, Server or the Initial Catalog doesn't exist or the username or password is invalid..So is there a way for me to do that? aside from using exceptions. Thanks in advance!!Code:string sqlConnStr; sqlConnStr = @"Data Source = DAIMOUS\SQLEXPRESS; Initial Catalog=BCMD; User ID=dbuser; Password=dexxa69++"; SqlConnection sqlConn = new SqlConnection(sqlConnStr); sqlConn.Open(); string qryStr = "select Max(id) as u_id from users"; SqlCommand sqlCmd = new SqlCommand(qryStr, sqlConn); SqlDataReader reader = sqlCmd.ExecuteReader(); while (reader.Read()) { MessageBox.Show((string)reader["u_id"].ToString ()); } reader.Close(); sqlConn.Close();




Reply With Quote