Database connection problem.......I think! :-)

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Hi all,

1st post here so................:-)

I am using VS.Net and coding in VB. I am following some examples from a book
that shows a connection string as:-

sqlcnn = new sqlconnection("data source=(local);initial
catalog=Northwind;integrated security=SSPI")

My server is the VS.Net default, ie. \\computername\NetSDK, therefore the
above in my code becomes:-

sqlcnn = new sqlconnection("data source=MyComputer\NetSDK;initial
catalog=Northwind;integrated security=SSPI")

I have used this in two different examples. On one it appears to work
sporadically and on the most recent I am receiving an 'Access is Denied'
runtime error and the handler refers to an UnauthorisedAccessException at
the point in code that refers to the Class where the connection is being
made. Therefore I am assuming that it is a problem with connecting to the
sql database......but not sure how to be certain or what the problem might
be. The dB is located properly and uses the default Windows Authentication.

It is not as simple to step through this as the 'example' is a client/host
example with Object Pooling.

Any thoughts?????

Cheers,

Phil
 
Phil,

Wit SQL is the datasource the SQL servername, not the path as you probably
expect from ms-access.

When you use MSDE local as test, than that local is already OK or you can
replace it for the servername.

I hope this helps?

Cor
 
Sorry Cor,

Not sure whether I understood exactly what you were trying to explain but
maybe I got the gist....................however, for whatever reason (and I
don't know why!), my coded connections do not 'like' the (local)
reference....it does not work on my machine...in fact, I have tried on both
my laptop and desktop with the same response. Have you any other
suggestion(s)?

Cheers,

Phil
 
Hi,
data source is the name or IP address of your computer,
not a path to a directory.
 
Phil,

Where is the database located?

Cor

Phil said:
Not sure whether I understood exactly what you were trying to explain but
maybe I got the gist....................however, for whatever reason (and
I
don't know why!), my coded connections do not 'like' the (local)
reference....it does not work on my machine...in fact, I have tried on
both
my laptop and desktop with the same response. Have you any other
suggestion(s)?

Cheers,

Phil
 
Sorry guys,

I could have perhaps given more info:-

I am running a single PC with MSDE on XP. The 'example' I am trying to work
through is creating a serviced component with object pooling. This perhaps
sounds more extravagant than the fairly simple code. The serviced component
has a default constructor that 'should' create a connection to the Northwind
Db. It also has a couple of methods that return dataset results based on a
passed SQL query from the calling app.

The SQL Service Server Manager shows:- Running - \\PHILSPC\NetSDK - MSSQL
Server

The calling app. instantiates the Serviced Component with:-

nsc = New NorthwindSC

This is the line in code that returns the Access is Denied!

Hope this helps you to help me :-). Thanks for the input so far....please
ask further questions!

Phil
 
Phil,

Why not make a test solution,
Just drag a SQLconnection to your screen.
Than go to the properties of that and start the wizard.
Take than only a look at the created datasource, and forget the rest.

That is what I would do in your situation.

I hope this helps,

Cor
 
Back
Top