I am a beginner in using Asp.NET with C# and it is my first time I am trying to establish a connection with an SQL server 2005 database:
Here is my simple code to connect to the sql server database,I am getting the text message set in the label. Is my problem in the connectionString ??? if so please show me examples how to write it and ow to get the server name and write it correctly ....or how to specify the database name (all path or just database name??)
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("server = Saher;Database=Database.mdf;integrated security = true");
try{
connection.Open();
}
catch{
lblMessage.Text = "COULDN'T CONNECT to Stupid database";
}finally{
connection.Close();
}
}
Thanks,