Showing posts with label labs. Show all posts
Showing posts with label labs. Show all posts

Friday, March 30, 2012

Having some trouble connecting to a database....

I am doing one of the Microsoft virtual labs "Creating ASP.NET Web Applications with C# - Part 2" using Visual Web Developer Express. I am trying to fill a gridview with database information, but it gives me the error

"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)".

This is on the local machine that I am executing the code.

public void BindGrid(string sortfield) {//Create DataAdapter to fetch data from Prodcuts table SqlDataAdapter myCommand =new SqlDataAdapter("select * from Products", myConnection);//Create dataset and fill it with Product data DataSet ds =new DataSet(); myCommand.Fill(ds,"Products");//Bind Product data to Datagrid DataView Source = ds.Tables["Products"].DefaultView; Source.Sort = sortfield; dgProducts.DataSource = Source; dgProducts.DataBind(); }

It stops on the line "myCommand.Fill(ds, "Products"); and points out the error mentioned earlier. I am not sure what to do...any help would be greatly appreciated, thanks in advance, and I apologize as well if I have not pointed out enough information.

What does your connection string look like?|||

check this link for help:

http://support.microsoft.com/kb/914277/en-us

Thanks

|||

First of all, thank you both greatly for responding.

Smalltalk, here is the connection string:

myConnection = new SqlConnection("server=localhost;database=northwind;Trusted_Connection=yes");

Jpazgier, my connections are set at local and remote connections, plus the server is on the same machine, I have no idea why it mentions that error for me.

Thanks again, guys.

|||

Hi GWShane,

Please make sure that the server is the default instance on your machine. If you're using SQL Express, the default name for this instance might be SQLExpress. In this case, you might need to add the instance name to the DataSource like:

myConnection = new SqlConnection("server=localhost\\SQLExpress;database=northwind;Trusted_Connection=yes");

Wednesday, March 7, 2012

Hands-on labs feedback

Whoever decided - http://www.mcwtech.com/? - to lock the material on these
labs [http://msdn.microsoft.com/sql/2005/2...s/default.aspx] beyond compare
has made one pissed off dev out of me...
For god's sake you can't even select the damn queries off the freaking PDFs...
Aaahhgggrrr!!
I think i better call it a stinking day.
Which one of them is causing you problems? The lab manuals I get from there
are Word doc's and I have no problem coping the text/queries.
Regards
Steen
Francisco Lopez wrote:
> Whoever decided - http://www.mcwtech.com/? - to lock the material on
> these labs [http://msdn.microsoft.com/sql/2005/2...s/default.aspx]
> beyond compare has made one pissed off dev out of me...
> For god's sake you can't even select the damn queries off the
> freaking PDFs...
> Aaahhgggrrr!!
> I think i better call it a stinking day.
|||Hello Steen,
I was playing with the SQL Server 2005 Beta 2 Resource Kit Hands-On Labs
DVD I got at a conference.
Maybe I should try downloading from the website.
Thanks.

Hands-on labs feedback

Whoever decided - http://www.mcwtech.com/? - to lock the material on these
labs [http://msdn.microsoft.com/sql/2005/2005Labs/default.aspx] beyond compare
has made one pissed off dev out of me...
For god's sake you can't even select the damn queries off the freaking PDFs...
Aaahhgggrrr!!
I think i better call it a stinking day.Which one of them is causing you problems? The lab manuals I get from there
are Word doc's and I have no problem coping the text/queries.
Regards
Steen
Francisco Lopez wrote:
> Whoever decided - http://www.mcwtech.com/? - to lock the material on
> these labs [http://msdn.microsoft.com/sql/2005/2005Labs/default.aspx]
> beyond compare has made one pissed off dev out of me...
> For god's sake you can't even select the damn queries off the
> freaking PDFs...
> Aaahhgggrrr!!
> I think i better call it a stinking day.

Monday, February 27, 2012

Hands-on labs feedback

Whoever decided - http://www.mcwtech.com/? - to lock the material on these
labs [http://msdn.microsoft.com/sql/2005/...bs/default.aspx] beyond c
ompare
has made one pissed off dev out of me...
For god's sake you can't even select the damn queries off the freaking PDFs.
.
Aaahhgggrrr!!
I think i better call it a stinking day.Which one of them is causing you problems? The lab manuals I get from there
are Word doc's and I have no problem coping the text/queries.
Regards
Steen
Francisco Lopez wrote:
> Whoever decided - http://www.mcwtech.com/? - to lock the material on
> these labs [http://msdn.microsoft.com/sql/2005/...bs/default.aspx]
> beyond compare has made one pissed off dev out of me...
> For god's sake you can't even select the damn queries off the
> freaking PDFs...
> Aaahhgggrrr!!
> I think i better call it a stinking day.|||Hello Steen,
I was playing with the SQL Server 2005 Beta 2 Resource Kit Hands-On Labs
DVD I got at a conference.
Maybe I should try downloading from the website.
Thanks.