Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET Databases Also see the forum ASP Databases for more general discussions of ASP database issues not directly related to these books.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 15th, 2003, 04:55 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem making an objConnection

Initially in CH03 it tells you to make an object connection to the "Northwind" sample database as such:

Dim strConnection As String = "server=(local)\NetSDK; database=Northwind; " & _
                     "integrated security=true"

That code works fine, unfortunately every other example says to make connection using this rather than the code listed above:

Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")

For some reason whenever I type the the code directly above, the ASP can't make a connection giving me this error code:

The ConnectionString property has not been initialized.
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.InvalidOperationException: The ConnectionString property has not been initialized.

Source Error:


Line 20: Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")
Line 21: Dim objConnection As New SqlConnection(strConnection)
Line 22: objConnection.Open()
Line 23:
Line 24: ' Get and display count

Did I set something up incorrectly or is this an error with the book itself. For GP the book is called: "Beginning ASP.NET Databases using VB.NET"

Any assistance would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old June 16th, 2003, 04:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

In Web.config file of your application <appSettings> section has to contains the key named Nwind.

Code:
<appSettings>
    <add key="NWind" value="server=(local)\NetSDK; database=Northwind; integrated security=true" />
</appSettings>
...but the Soon is eclipsed by the Moon
Reply With Quote
  #3 (permalink)  
Old June 16th, 2003, 07:55 AM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Worked like a charm, thanks for your help, I only wish they would have stated that in the book it would have saved me a great deal of heartache.
Reply With Quote
  #4 (permalink)  
Old September 26th, 2003, 10:06 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Help! I'm also having problems making a connection to the "LOCAL" SQL Server 2000 Northwind database in Chapter 03 (page 67) of "Beginning ASP.NET Databases using VB.NET."

I have the full development version of SQL Server 2000 installed on my PC. In Visual Studio.NET's Server Explorer, my server name is shown as "PAUL" (the Northwind database is shown under that server name). I also show a PAUL.Northwind.dbo Data Connection, and it too is shown as being open.

Here is my modified connection string:
Dim strConnection As String = "server=PAUL; database=Northwind; " & _
                                "integrated security=true;"

I'm getting the following error message when I try to view the page in a browser:
System.Data.SqlClient.SqlException: Login failed for user 'PAUL\ASPNET'

I have no idea where that "\ASPNET" is coming from after the server name. Also, I've tried just about every combination I can think of to replace the server name (PAUL, \PAUL, (local)\PAUL, (local)\NetSDK) without any success. I'm using Windows 2000 authentication, so no User ID (UID) or Password (PWD) should be necessary in the connection string. The error message "indicates" that it has found the database, but cannot log in.

If I modify the connection string (and related fields in the strSQL string) to connect to another SQL Server 2000 database on my web hosting company's web server, including both a User ID and Password, it connects perfectly! What should be easy is difficult, and what should be difficult is easy!! Please help me understand how to connect to a LOCAL Northwind database. Thank you.

Clutch Cargo
Reply With Quote
  #5 (permalink)  
Old September 28th, 2003, 06:27 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After three days of knocking my head against the wall, I got it figured out. A kind responder on another forum (http://www.asp.net) helped me realize that with the full-blown version of SQL Server 2000 vs. the scaled-down Microsoft SQL Server Desktop Engine (MSDE), rights to the Northwind database need to be assigned to the ASPNET user through SQL Server's Enterprise Manager (something I feel the authors should have addressed since so many readers already have SQL Server on their PCs and didn't need to download the MSDE at all).

Clutch Cargo

Reply With Quote
  #6 (permalink)  
Old January 18th, 2004, 10:52 PM
Registered User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Cincinnati, , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Clutch Cargo
 After three days of knocking my head against the wall, I got it figured out. A kind responder on another forum (http://www.asp.net) helped me realize that with the full-blown version of SQL Server 2000 vs. the scaled-down Microsoft SQL Server Desktop Engine (MSDE), rights to the Northwind database need to be assigned to the ASPNET user through SQL Server's Enterprise Manager (something I feel the authors should have addressed since so many readers already have SQL Server on their PCs and didn't need to download the MSDE at all).

Clutch Cargo
Clutch,
 I think I might be having the same problem. I'm stuck on page 67. However I don't get any error messages.

My problem is this: I can get the data grid to show. When I clicked on View Source , the page was not even compiled. So I tried WebMatrix. A free ASP web serve with limite capacity. Using WebMatrix worked. The page loaded, and the grid displayed, and clicking on View Source showed a fully compiled page.

I would rather use IIS


    Can you tell what I need to have Turned On so I can get error messages if any?
    Also, can you tell me how to give the permission to the ASPNet user?

Maybe using Webmatrix uses different permissions, thus allowing access? I really don't know.

My set up:
SQL 2000 Personal
Win 2k
IIS5
VS.Net

Any suggestions would be great.

Thanks,
rwiethorn





Reply With Quote
  #7 (permalink)  
Old February 12th, 2004, 08:53 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i am having the same problem that the grid is just not showing. but it is not giving me an error message. you said you used webmatrix. i am new to this. can you please tell me how to do that? the current code that i have is :

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

<html>
  <head>
    <title>Beginning ASP.NET Databases Chapter 3</title>
  </head>

  <body>
    <h4>First Example: Listing data from the Employees table</h4>
    <asp:DataGrid id="dgNameList"
                  runat="server"
                  Gridlines="None"
                  BackColor="LightBlue"
                  CellPadding="5"
                  CellSpacing="5"
                  BorderWidth="2"
                  BorderColor="Black"
                  ToolTip="Includes only those employees who are at HQ" />
  <body>
</html>

<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
  Dim strConnection As String = "server=(local)\NetSDK; database=Northwind; " & _
                                "integrated security=true"
  Dim objConnection As New SqlConnection(strConnection)

  Dim strSQL As String = "SELECT FirstName, LastName, Country " & _
                         "FROM Employees;"
  Dim objCommand As New SqlCommand(strSQL, objConnection)

  objConnection.Open()
  dgNameList.DataSource = objCommand.ExecuteReader()
  dgNameList.DataBind()
  objConnection.Close()
End Sub
</script>

if you can please PLEASE PLEASE let me know how i can change this i would really appreciate it. i do have the correct systems running on my computer like they say in the book.
if you can email me a response as well so that i know that it was replied to i would really appreciate it.
i had everything working on my old computer but then i got a new one and it doesnt work anymore.
thanks again for any assistance
tiki

by the way, for the poster who needed to add a line to their web.config file to get it working, the book does state to do that. if you actually download the code from the site, it's in there as well. i dont have the book in front of me so i cant tell you what page it's on but if you want i can look it up.
Reply With Quote
  #8 (permalink)  
Old February 14th, 2004, 03:07 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik Send a message via Skype™ to melvik
Default

dear friend:
I can not see any USER name to connect DataBase.
use follocing string to connect ur DB.

Code:
Dim strConnection As String = "data source=(local);initial catalog=Northwind;password=;persist security info=True;user id=sa;packet size=4096"
HTH.

Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem making a Database Connection ROBEDAVI00 VB Databases Basics 1 December 29th, 2007 08:00 PM
Problem regarding the making of virtual directory CsharpHelp C# 0 October 27th, 2005 01:07 AM
Problem in making database file address virtual akhilvira ASP.NET 1.0 and 1.1 Basics 0 January 4th, 2005 12:33 AM
making windows Stuby085 Visual C++ 2 September 1st, 2003 02:28 AM
Making a template , Which one is better? studenttwok Beginning PHP 4 July 8th, 2003 10:43 PM



All times are GMT -4. The time now is 05:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.