Can't open connection to SQL Server DB

  • Thread starter Thread starter Sandy
  • Start date Start date
S

Sandy

Hi!

I am trying to open a connection to a SQL Server database
using just the Framework, Notepad and the browser. I keep
getting the error message "SQL Server does not exist or
access is denied."

I am using the following for the connection:

Dim conPubs As SqlConnection
ConPubs = New SqlConnection ("Data
Source=localhost;Initial Catalog=PUBS;Integrated
Security=SSPI;")
ConPubs.Open()

In Page_Load of the script.

I can take the same notepad aspx page and put it into
Visual Studio .NET and it connects without a problem.

Anyone out there have any ideas?

Sandy
 
It is security, the "SQL Server does not exist" part is misleading. To
verify this, make your connection string in the aspx something like:
Data Source=localhost;Initial Catalog=PUBS;User ID=XXX;Password=YYY;Persist
Security Info=True;

If you want to use integrated security as in your example, you must use
impersonation on the server. Search for "active server pages and
impersonation".
The following is good literature as well.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetch05.asp
 
You could try to create an odbc connection to see if you can even see the
box sql server is on.
 
I know, they write 22 pages on a half page article. And yes, it will work
through VS .NET, then your user account is the Admin account, but through
the WEB you connect as the ASPNET user. To use impersonation, there are two
steps.
(1) Switch off anonymous access on the web folder. To do this, open Internet
Services Manager (under Administrator Tools), look under the Default Web
Site for your application folder, right click on it, go Properties,
Directory Security, then the top Edit button, and un-check anonymous access.
(2) Make the following entry in the "web.config" file, right under the line
that says <system.web> add a line that says <identity
impersonate="true"/>
 
Chris -

Got it! Thank you, thank you, thank you!

I am just curious about the password for Z/Administrator.
It shows ten placeholders. My password is six letters.
Any idea why?

Sandy
 
Sandy, it's a decoy, so someone won't know how may characters are in the
password if they manage to stumble upon that window, I guess. Glad you are
up and running.
 
Chris -

Thanks again!

Sandy
-----Original Message-----
Sandy, it's a decoy, so someone won't know how may characters are in the
password if they manage to stumble upon that window, I guess. Glad you are
up and running.




.
 
Back
Top