Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 3rd, 2005, 7:18 PM   #1
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
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
BlazingWolf is offline   Reply With Quote
Old Oct 4th, 2005, 8:26 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Oct 4th, 2005, 9:04 AM   #3
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
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
melbolt is offline   Reply With Quote
Old Oct 4th, 2005, 3:50 PM   #4
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
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
BlazingWolf is offline   Reply With Quote
Old Oct 4th, 2005, 5:12 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC