Re: Dot Net 2.0 or SQL Server 2005 problem?



Ok, let's take a deep breath.
1) When connecting to SQL Server one should use the SqlClient .NET Data Provider. I'm sorry, but I assumed that you were doing so. This means you should have code that instantiates a SqlConnection object and sets the ConnectionString property of that object. Your first ConnectionString (shown below) seems correct.
2) This ConnectionString will not be correct for the Odbc .NET data provider or the Oledb .NET data provider. I do not encourage anyone to use these to access SQL Server.
Let's see the code you're using. Be sure to check out http://betav.com/blog/billva/2006/06/getting_and_staying_connected.html which details these and other issues.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
-----------------------------------------------------------------------------------------------------------------------


"B. Chernick" <BChernick@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A1FEA4C6-7148-4221-B965-98FA86AF82C2@xxxxxxxxxxxxxxxx
I'm getting more confused. I was finally able to connect with AdventureWorks.
The whole point of my post was to get my code to the point where I could run
the chapter 3 example. I have translated into vb since I am not familiar
with C#.

Using the same style connection string that I used to connect with
AdventureWorks ("Data Source=.\SQLEXPRESS;Initial
Catalog=TK431Chapter8;Trusted_Connection=True; ") causes a crash:

[Microsoft][ODBC Driver Manager] Data source name not found and no default
driver specified

If I add the provider declaration the string becomes:"Provider=sqloledb;Data
Source=.\SQLEXPRESS;Initial Catalog=TK431Chapter8;Trusted_Connection=True; "

and I get the exception: Login failed for user '<user name>'. The user is
not associated with a trusted SQL Server connection.

This database is on the same server instance as AdventureWorks.

(Incidentally I am running Windows XP Pro and my Windows login id has
computer administrator authority.)

"William (Bill) Vaughn" wrote:

1) Since SQL Server Express is installed on the local system, no other
protocols are needed -- shared memory should be best and you don't need to
turn on the browser or enable any ports.
2) Accessing the local SQLEXPRESS instance should be clear by now...
"SERVER=.\SQLEXPRESS"
3) Accessing the selected database (on this instance) might be an issue if
the database (adventureworks) does not know who you are. To deal with this
issue, you either need to log on with a Windows domain account that's in the
Administrators group or create a Login on SQL Server for your windows
account. I assume you aren't using Mixed Mode security. These accounts can
be setup with SQL Server Management Studio Express (downloadable). Just make
sure your Windows domain account is granted sufficient rights to the target
DBMS.

hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
-----------------------------------------------------------------------------------------------------------------------


"B. Chernick" <BChernick@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A163EACC-8F54-4E37-898D-002E281C7503@xxxxxxxxxxxxxxxx
>I have rather hastily installed VB 2005 Express and SQL Server 2005 >Express
> on my machine and I haven't much experience with either. So far as I > can
> remember I have mostly used default settings. SQL Exp. is set to use
> Windows
> validation. I already have SQL Server 2000 Developer installed so my > SQL
> 2005 Exp. instance is called SQLEXPRESS. I'm not sure whether I've
> forgotten
> how to code or I have a server problem.
>
> As a test, I am trying a basic connect with ADO.Net and I am getting
> nowhere. Here is the code.
>
> c.ConnectionString = "Data Source=SQLEXPRESS;Initial
> Catalog=AdventureWorks_Data;Trusted_Connection=True; "
> c.Open()
> Dim da As New SqlDataAdapter("Select * from Store", c)
> da.Fill(ds, "Store")
> c.Close()
>
> It crashes on open. The error message is:
> 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)
>
> Where's the best place to start looking? (Remote connections?)

.



Relevant Pages

  • Getting to the bottom of MSDE network connection problems ...
    ... but other than that it is MSDE 2000 with sp3a already applied. ... I've finally figured out the connection problems associated with this, ... and it seems the problems are due to Windows XP and not MSDE. ... the enterprise/standard versions of SQL server won't install ...
    (microsoft.public.sqlserver.msde)
  • Re: Remote connection failed
    ... If you are going over a remote connection or are not logging ... into the domain where SQL Server is then no, Windows ... authentication won't work. ...
    (microsoft.public.sqlserver.connect)
  • Re: Bizzare SQL Network Error
    ... The bizzare thing is that, the same connection string, the same code to ... In a windows APP it works fine, in a Web APP I get ... >>I am trying to connect to a default instance of SQL Server 2000 Enterprise ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problems Using Laptop As SQL Server - Log On Failed
    ... > connected to the network and no password for windows. ... > the name of the laptop as name of the SQL Server. ... > trusted SQL Server connection ... you have to change the authentication mode... ...
    (microsoft.public.sqlserver.msde)
  • Re: No Windows, Only SQL Server Authentication
    ... To establish a Windows authenticated connection from OSQL, ... SQL Server programatically. ... Your connection string needs to specify the type of authentication desired. ...
    (microsoft.public.sqlserver.security)