locked
ASP page to SQL DB RRS feed

  • Question

  • Hello,

    I am very new to ASP and IIS (Server2008R2) and need instructions on how to setup the correct connections to SQL (2008R2) to access db's. Keeping it simple would be great at first I would assume...thanks

    Getting the following errors when I tried a few things:

    Source Error:
    Line 8:    protected void Page_Load(object sender, EventArgs e)
    Line 9:    {
    Line 10:       using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["CTCDbConn"].ToString()))
    Line 11:       {
    Line 12:           SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM ConsistancyGroups", cn);

    Source File: c:\inetpub\wwwroot\test2db.aspx    Line: 10

    Stack Trace:
    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.test2db_aspx.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\test2db.aspx:10
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
       System.Web.UI.Control.OnLoad(EventArgs e) +131
       System.Web.UI.Control.LoadRecursive() +65
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2427
    
    Thursday, April 25, 2013 9:41 PM