Click here to Skip to main content
15,923,852 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace sqlaccess
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           SqlConnection con = new SqlConnection();
           con.Open(); //getting error over here
            SqlCommand cmd=new SqlCommand();
           con.Close();
        }
    }
}
Posted
Updated 25-Sep-14 4:13am
v2
Comments
[no name] 25-Sep-14 10:10am    
Of course you get an error there. Where is your connection string?

1 solution

You need to provide a connection string. There are tons of examples online and you should also refer to http://www.connectionstrings.com/
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900