Click here to Skip to main content
15,906,766 members
Home / Discussions / C#
   

C#

 
QuestionC# and local SQL server connection [Solved] Pin
JoplinsSlave21-Mar-11 23:20
JoplinsSlave21-Mar-11 23:20 
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 bullshit about username and password in the connection string? It's just a local database for god's f***ing sake!!!!

Thanks in advance,

Jop
modified on Tuesday, March 22, 2011 6:32 AM

AnswerRe: C# and local SQL server connection Pin
Pete O'Hanlon21-Mar-11 23:40
mvePete O'Hanlon21-Mar-11 23:40 
GeneralRe: C# and local SQL server connection Pin
JoplinsSlave21-Mar-11 23:53
JoplinsSlave21-Mar-11 23:53 
GeneralRe: C# and local SQL server connection Pin
Pete O'Hanlon22-Mar-11 0:04
mvePete O'Hanlon22-Mar-11 0:04 
GeneralRe: C# and local SQL server connection Pin
JoplinsSlave22-Mar-11 0:32
JoplinsSlave22-Mar-11 0:32 
GeneralRe: C# and local SQL server connection Pin
Pete O'Hanlon22-Mar-11 0:42
mvePete O'Hanlon22-Mar-11 0:42 
AnswerRe: C# and local SQL server connection Pin
Geoff Williams21-Mar-11 23:42
Geoff Williams21-Mar-11 23:42 
GeneralRe: C# and local SQL server connection Pin
JoplinsSlave21-Mar-11 23:57
JoplinsSlave21-Mar-11 23:57 
AnswerRe: C# and local SQL server connection Pin
Ravi Sant21-Mar-11 23:51
Ravi Sant21-Mar-11 23:51 
GeneralRe: C# and local SQL server connection Pin
JoplinsSlave22-Mar-11 0:04
JoplinsSlave22-Mar-11 0:04 
AnswerRe: C# and local SQL server connection Pin
Rob Philpott22-Mar-11 0:33
Rob Philpott22-Mar-11 0:33 
GeneralRe: C# and local SQL server connection Pin
Rob Philpott22-Mar-11 0:35
Rob Philpott22-Mar-11 0:35 
GeneralRe: C# and local SQL server connection Pin
Ravi Sant22-Mar-11 0:52
Ravi Sant22-Mar-11 0:52 
Questiondatagridview problems! Pin
King Boy21-Mar-11 19:54
King Boy21-Mar-11 19:54 
Questioncalling a web service at runtime Pin
Marcus Spitzmiller21-Mar-11 13:45
Marcus Spitzmiller21-Mar-11 13:45 
AnswerRe: calling a web service at runtime Pin
Pete O'Hanlon21-Mar-11 22:57
mvePete O'Hanlon21-Mar-11 22:57 
Questionproblem to connect to Oracle from my C# WinForm program Pin
Gali197821-Mar-11 10:12
Gali197821-Mar-11 10:12 
AnswerRe: problem to connect to Oracle from my C# WinForm program Pin
Wendelius21-Mar-11 10:26
mentorWendelius21-Mar-11 10:26 
AnswerRe: problem to connect to Oracle from my C# WinForm program Pin
Ian Shlasko21-Mar-11 10:30
Ian Shlasko21-Mar-11 10:30 
QuestionWindows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Chesnokov Yuriy21-Mar-11 1:26
professionalChesnokov Yuriy21-Mar-11 1:26 
AnswerRe: Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Pete O'Hanlon21-Mar-11 3:10
mvePete O'Hanlon21-Mar-11 3:10 
QuestionRe: Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Chesnokov Yuriy21-Mar-11 7:18
professionalChesnokov Yuriy21-Mar-11 7:18 
AnswerRe: Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Pete O'Hanlon21-Mar-11 8:23
mvePete O'Hanlon21-Mar-11 8:23 
QuestionRe: Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Chesnokov Yuriy21-Mar-11 10:06
professionalChesnokov Yuriy21-Mar-11 10:06 
AnswerRe: Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change Pin
Pete O'Hanlon21-Mar-11 10:42
mvePete O'Hanlon21-Mar-11 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.