Database connection issue

Discussion in 'Databases' started by tlandsman, Sep 9, 2012.

  1. Hiu! I'm trying to figure out how to set up a database connection and can't seem to figure it out. I'm writing an page. Can someone tell me what I'm doing wrong:

    <%@ Page Language="C#" Debug="true" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <Script language = "c#" Runat="Server">

    void Page_Load(){
    string strResultsHolder;

    SqlDataReader vDataReader;
    SqlConnection conPubs;
    SqlCommand cmdSelect;

    conPubs = new SqlConnection(";database=DB_46795_database;uid=DB_46795_database_user;pwd=password");
    strResultsHolder = "Connection successful";


    catch (Exception e)
    strResultsHolder = "Connection failed";

    //display results in divDisplay
    divDisplay.InnerHtml = strResultsHolder;

    }//end Page_Load
    Last edited by a moderator: Oct 14, 2015
  2. ComputerMan

    ComputerMan Winhost Staff

    Last edited by a moderator: Oct 14, 2015

Share This Page