Setup SqlConnection (C#)
<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <script Language="c#" runat="server"> void Page_Load() { // string strConnection = "user id=sa;password=;"; // strConnection += "initial catalog=northwind;data source=EWANB;"; //strConnection += "Connect Timeout=30"; string strConnection = "Data Source=whsql-v08.prod.mesa1.secureserver.net;Initial Catalog=DB_49907;User ID=java2suser;Password='password';"; data_src.Text = strConnection; SqlConnection objConnection = new SqlConnection(strConnection); try { objConnection.Open(); con_open.Text="Connection opened successfully.<br />"; objConnection.Close(); con_close.Text="Connection closed.<br />"; } catch (Exception e) { con_open.Text="Connection failed to open.<br />"; con_close.Text=e.ToString(); } } </script> <html> <body> <h4>Testing the data connection <asp:label id="data_src" runat="server"/></h4> <asp:label id="con_open" runat="server"/><br /> <asp:label id="con_close" runat="server"/><br /> </body> </html>