المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# and local SQL server connection



C# Programming
03-22-2011, 10:12 PM
Hola,

So here's the thing..

I'm using Visual Web Developer 2010 Express and SQL Server 2008, and I'm trying to connect to this goddamn database using C#.

I've created an ASP.NET Empty Website, and I've created an SQL Server Database in the project as well.

So here's how my Page_Load function looks (where I try to connect to the database):

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlCon = new SqlConnection("server=localhost;database=Database;Trusted_Connection=yes;connection timeout=8");

try
{
sqlCon.Open();
}
catch (Exception err)
{
errorLbl.Text = err.ToString();
}
}But it just won't work...
I'm obviously doing something wrong here, but what?
And what's this bullsh*t about username and password in the connection string? It's just a local database for god's f***ing sake!!!!

Thanks in advance,

Jop