Wrox Programmer Forums
|
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 3rd, 2004, 12:02 AM
Authorized User
 
Join Date: Jan 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL server...

Hi, I am working on the project in Beginning Web Programming VB.NET and Visual Studio.NET

The database for this project was contained within a file called Friends_Data.MDF The instructions said to attach this file to the MSDE server, which I did. I am now trying to access the database via a web form to create a new entry in the database. The connection string I am using is

con = New SqlConnection("data source=(NetSdk;initial catalog=Friends;user id=sa")

However, when trying to create a new entry I get the error listed below. Does anyone have any idea on how I can correct this problem?

Thanks much,

Michael

Error Message:

Code:
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error: 


Line 101:            con = New SqlConnection("data source=(local)\NetSdk;initial catalog=Friends;user id=sa")
Line 102:            cmd = New SqlCommand(sql, con)
Line 103:            con.Open()
Line 104:
Line 105:            Try
 

Source File: c:\inetpub\wwwroot\FriendsReunionUI\secure\NewUser.aspx.vb    Line: 103 

Stack Trace: 


[SqlException: SQL Server does not exist or access denied.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnection.Open()
   FriendsReunionUI.NewUser.btnAccept_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\FriendsReunionUI\secure\NewUser.aspx.vb:103
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()
I am using Windows NT Integrated security to log into the database.
  #2 (permalink)  
Old February 3rd, 2004, 06:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

How is your MSDN instance called? Are you sure it's called NetSDK?

Can you see your SQL Server using the Enterprise Manager (if you have it available)? That way, it's easy to see the instance name.

Also, you say you're using Integrated Security to log into the database. Do you mean you set your MSDN installation to Integrated only? If so, you'll need to modify your connection string. Right now you're using SQL Server Authentication because you're using a User ID. Take a look here for more info on a connection string that uses Integrated Security (Integrated Security needs to be set to SSPI, or alternatively, use Trusted_Connection=Yes.)

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old February 3rd, 2004, 12:44 PM
Authorized User
 
Join Date: Jan 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help, Imar.

My MSDN instance is not called NetSDK. I think it is just my computer name. I can see my SQL Server in Enterpirise manager, but I am not sure where to look to confimr the instance name.

Based on the information on the link you sent, I changed my connection string to:

"data source=MRANDALL;" & "Initial Catalog=Friends;" & "Integrated Security=SSPI"

There template was:

"Data Source=(local);" & "Initial Catalog=mySQLServerDBName;" & "Integrated Security=SSPI"

This seem to take care of the error message I was receiving, but now I have a new one:

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'MRANDALL\ASPNET'.

Source Error:


Line 102:
Line 103: cmd = New SqlCommand(sql, con)
Line 104: con.Open()
Line 105:
Line 106: Try


Source File: c:\inetpub\wwwroot\FriendsReunionUI\secure\NewUser .aspx.vb Line: 104

Stack Trace:


[SqlException: Login failed for user 'MRANDALL\ASPNET'.]
   System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnection.Open()
   FriendsReunionUI.NewUser.btnAccept_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\FriendsReunionUI\secure\NewUser .aspx.vb:104
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
   System.Web.UI.Page.ProcessRequestMain()


Any thoughts? Am I moving in the right direction?

-Michael



  #4 (permalink)  
Old February 3rd, 2004, 03:58 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

(I said MSDN a couple of times, but of course I meant MSDE)

Sorry it took me a while to answer you. I first had to get humiliated on the squash-court... ;)

Anyway, yes, you're getting closer. Your ASP.NET pages can now at least see your SQL Server. Now you have to make sure that the ASPNET account has sufficient rights to the database Friends.

By default, your ASPX pages will run under the context of the ASPNET account. (For "classic ASP", this was the IUSR_MachineName account).
To add this account, add it to you Login list under Security in SQL Server first, then grant it access to the Friends database.

If you have the SQL Server Enterprise Manager, this is easy to do. If you have just the MSDE, you'll need to execute some SQL statements to add the account.

Hope this helps, and if not, let me know.....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old February 3rd, 2004, 04:32 PM
Authorized User
 
Join Date: Jan 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hellaluja!

Thanks so much Imar!

  #6 (permalink)  
Old February 3rd, 2004, 04:57 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome ;) Glad it worked out.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old July 26th, 2004, 09:21 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got the same problem as Michael but after I followed your solution. it worked out. I just want to thank you.
Thank you so much for your helpful answer.

eaid





Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflict in SQL Server 2000 and SQL Server 2005 ayan.mukherjee SQL Language 0 June 30th, 2008 03:34 AM
SQL Server Reg. SQL Server does not exist error Arsi SQL Server 2000 1 June 11th, 2008 11:20 AM
migrating from sql server 2000 to sql server 2005 abinashpatra SQL Server 2005 2 December 1st, 2006 03:45 PM
SQL Server sync with net server and browser server ne SQL Server DTS 0 June 13th, 2005 06:29 PM
SQL Server 7.0 talking to SQL Server 2000 msavage SQL Server 2000 1 August 20th, 2003 01:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.