![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Ado .net
I'm trying to connect to SQL 2005 Express Edition. It just times out whenever I try to connect. When I use the GUI in Visual Web Developer it is able to connect which leads me to believe it is my code.
//Connection String & Command
string sConn = ("server=localhost; uid=sa; pwd=; database=actprep;");
string sCmd = "Select * FROM students";
SqlDataAdapter adapter = new SqlDataAdapter(sCmd, sConn);
DataSet dataset = new DataSet();
adapter.Fill(dataset, "students");
//Bind data to datagrid
DataTable tStudents = dataset.Tables[0];
DataGrid gStudents = new DataGrid();
gStudents.DataSource = tStudents;
gStudents.DataBind();Any suggestions?
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
check the format of your connection string... (see connectionstrings.com)
I am working on a C# Oracle application using ODP.Net and a timeout was caused by a faulty DataSource value.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
I had this same problem in an application of mine the other day, server explorer could connect but I kept timing out in my program.
I found the problem was that my firewall was blocking the port of my SQLServer, better double check this as well.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Turns out it was because 'localhost' didn't work. I put that in there after I tried '.\SQLEXPRESS' which didn't work because \. You need to put '.\\SQLEXPRESS'.
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
glad you got it working man
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|