Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection for pubs DB failure

Status
Not open for further replies.

Kenny62

Programmer
Mar 3, 2004
54
GB
Hi - i'm trying to connect to the a local pubs DB (SQL7).

Connection string is:
Public OledbPubsConnString As String = "Provider=SQLOLEDB.1;Data Source=(local);" _
& "User ID=sa;Password=sa;Initial Catalog=pubs"

' The connection to the Pubs database.
Dim cn As New OleDbConnection(OledbPubsConnString)

page load event call bindbooklist - which in turn open DB.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Me.IsPostBack Then
BindBookList()
End If
End Sub


Sub BindBookList()
' Open a connection to Pubs, if necessary.
If cn.State = ConnectionState.Closed Then cn.Open()
...
I get the following exeception when the cn.open() is executed:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

Source Error:


Line 47: Sub BindBookList()
Line 48: ' Open a connection to Pubs, if necessary.
Line 49: If cn.State = ConnectionState.Closed Then cn.Open()
Line 50:


SQL is running, i don't understand what is going on - i sense that problem lies with the account 'sa'. Please explain, what do i need to change on the account to connect successfully. Thanks in advance. Mr K.
 
Stab in the dark -

Try changing (local) to your machine's IP address. I seem to remember coming across that problem in the past (not totally sure though ;)).

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Thanks for your help - problem solved.
Reference material state that using <machine name> or (local)on the connection string should work. These methods work fine for a windows form app - why not for aspnet? Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top