c# - How to test a DNS connection? Just as the button "Test" in the ODBC Data Source Administrator? -
check out. can add below code in form application on button click event.
string sqlconn = "data source=yourservername;initial catalog=dbname;user id=dbuser;password=dbuserpws;application name=mytestapp;" //for port number //string sqlconn = "data source=yourservername,5432;initial catalog=dbname;user id=dbuser;password=dbuserpws;application name=mytestapp;" sqlconnection myconnection = new sqlconnection(sqlconn); try { myconnection.open(); messagebox.show("connected successfully"); } catch(exception e) { messagebox.show("error. error message:" + ex.message); }
Comments
Post a Comment