I am learning ASP.NET from teach yourself ASP.NET in 24 hours. When i try to connect to the SQL Server i get an error "SQL Server does not exist or access denied".
SQL appears to exist, and to be running. I am trying to connect through Localhost.
Where should i be looking if access is being denied by a firewall and how should i disable it
Connection to local SQL always uses Shared Memory Network Library by default, which should not be blocked. Please post your error message and connection string.
|||Hi Lori-Jay
The message is:
Unable to connect to database server.
SQL does not exist or access denied.
ConnectionOpen(Connect())
|||Hi, did you forget to post your connection string?|||Hi,
Where do i find the connection string? I am simply using the example in the book which gives me some buttons and text boxes to fill in.
These are
SQL Server authentication button on
User name which I completed as instructed as SA
And the password which I used to install MSDE
And then I hit "Create a new database"
I then got the error above.
Where would I find the connection string?
|||So you're using MSDE, thus leads us closer to the answer. Are you using ASP.NET 2.0? Sorry I'm not familiar with the example you mentioned, so if possible please give a link that I can follow to try the sample. Is it something like this?
http://download.microsoft.com/download/C/3/8/C3888A3E-52F8-4FE9-8E41-89150AB0302F/CreateDB.zip.exe
If yes, please open to sample solution with VS2005 and right click the form where you create the database (Form1.vb in this sample) in Solution Explorer, choose View Code. You should see some code like this:
Public Class Form1
' Initialize constants for connecting to the database
' and displaying a connection error to the user.
Protected Const SqlConnectionString As String = _
"Server=(local);" & _
"DataBase=;" & _
"Integrated Security=SSPI"
Protected Const ConnectionErrorMessage As String = _
"To run this sample, you must have SQL " & _
"installed. For " & _
"instructions on installing SQL, view the documentation file."
Protected didPreviouslyConnect As Boolean = False
Protected didCreateTable As Boolean = False
Protected connectionString As String = SqlConnectionString
.....
And explorer the 'Create database section you'll find this line which gets connectionString:
Dim connection As New SqlConnection(connectionString)
As we can see the default connection is made to local default SQL instance. So what you need to do is customizing the const that host connection string to point to your MSDE server name. For example:
"Server=myServer\myMSDESvr;" & _
"DataBase=;" & _
"Integrated Security=SSPI"
No comments:
Post a Comment