easy sql connection

A

AccessStarters

Can anyone please help me simply connect to northwind? Maybe some logical
steps that I may be missing?

I have tried many tutorials and they all give similar connections to the one
below.
Dim objConnection As SqlConnection = New SqlConnection("Data
Source=localhost;Integrated Security=SSPI;" & _
"Initial
Catalog=northwind")
I still cannot get a connection with sqlserver2000 (set to authentication
windows only). It is running.
TIA
Jill
Here is m entire test.aspx file (error code below too)
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">
Sub Page_Load()
Dim strConnection as String = "Integrated Security=SSPI;"
strConnection += "Initial Catalog=Northwind;server=localhost;"
strConnection += "Persist Security Info=no;"
strConnection += "Connect Timeout=30"
data_src.text = strConnection

Dim objConnection as New SqlConnection(strConnection)

'Now we attempt to open the connection
try
objConnection.Open()
con_open.text="Connection opened successfully.<br />"
objConnection.Close()
con_close.text="Connection closed.<br />"
catch e as Exception
con_open.text="Connection failed to open.<br />"
con_close.text=e.ToString()
end try
end Sub
</script>

<html>
<body>
<h4>Testing the data connection
<asp:label id="data_src" runat="server"/></h4>
<asp:label id="con_open" runat="server"/><br />
<asp:label id="con_close" runat="server"/><br />
</body>
</html>
---------------------------------------
error message
Testing the data connection Integrated Security=SSPI;Initial
Catalog=Northwind;server=localhost;Persist Security Info=no;Connect
Timeout=30
Connection failed to open.

System.Data.SqlClient.SqlException: SQL Server does not exist or access
denied. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnec
tionString options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
ASP.sql_connection_aspx.Page_Load()
 
E

Edge

AccessStarters said:
Can anyone please help me simply connect to northwind? Maybe some
logical steps that I may be missing?

I have tried many tutorials and they all give similar connections to
the one below.
Dim objConnection As SqlConnection = New SqlConnection("Data
Source=localhost;Integrated Security=SSPI;" & _
"Initial
Catalog=northwind")

Use
Data Source=(local)
instead of
Data Source=localhost
 
G

Guest

Hi Jill,

Do you have a named instance of SQL Server or default instance? Do you have
it at your local machine? Do you have privilges to access that instance and
the Northwind database?
 
A

AccessStarters

Not sure what you mean here
1. I have MSSQLSERVER as a service which is started. (don't know how to tell
if named or default instance?)
2. I can test it successfully from VStudio Server Explorer and is
successful.
3. I can show all say employeee recs from the enterprise manager
4. have tried Data Source=(local) instead of Data Source=localhost
5. have tried database instead of Initial Catalog
6. On my local machine (is called HOME). The sql server is called (LOCAL)
within a server group
7. I log on as Administrator and wouldn't know how to tell if I have
privilages to access an instance of Northwind.
8. My IIS works as can connect when doing tutorials with a jet Access
connection
9. i have win2000, use ie6, use zone alarm which have tried off and on.
10. Am curious to know if you copied and pasted the code below that it does
actually work - else I am completely confused.

Many thanks- hope the above helps...
 
A

AccessStarters

Thanks Joyjit
have been there and tried a few variations. Still at a loss.
Please see my reply to "TheLord" link as gave more parameters.
Appreciated!!
 
A

AccessStarters

Thanks Edge
Still at a loss.
Please see my reply to "TheLord" link as gave more parameters.
Appreciated!!
 
G

Guest

Hi,

Try add the ASPNET user account to the database Northwind users, (i.e give
the ASPNET user account privileges to access your SQL Server and the
Northwind db).

Please keep me updated.
 
G

Guest

Hello AccessStarters,

Yes I have tried it, just add the ASPNET user account (in your case
HOME\ASPNET user) to the Northwind users on your SQL Server and it will
connect successully; because you are using your code from ASP.NET wich uses
the ASPNET user account not the user account you use to log to Windows.

Please keep me updated :)
 
A

AccessStarters

that was it
thank you most kindly!!!
tHE LoRd T said:
Hello AccessStarters,

Yes I have tried it, just add the ASPNET user account (in your case
HOME\ASPNET user) to the Northwind users on your SQL Server and it will
connect successully; because you are using your code from ASP.NET wich uses
the ASPNET user account not the user account you use to log to Windows.

Please keep me updated :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top