Wrox Programmer Forums
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003
This is the forum to discuss the Wrox book Professional VB.NET 2003 by Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Jonathan Pinnock, Rama Ramachandran, Bill Sheldon; ISBN: 9780764559921
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 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
Old February 8th, 2005, 01:30 PM
Registered User
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 16 Question


I was trying to do the example program DatasetExample from Chapter 16 (pages 542 to 544). SQL Server and .NET are running on the same PC (local). When I tried to run the program I got an error for objConnection.Open(). Just to make sure the problem was not a typo, I tried downloading the code from Wrox and the same thing happened.
I modified the code a little to get an description of the error and here is what I got:

Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

I just installed SQL Server 2000 (and SP 3a) on my PC yesterday. Although I am good with Access, I am very new to SQL Server. I tried to select default options as much as possible during the install. My OS is windows 2000 Pro.

I went into Enterprise Manager and here is what I found:
1. Under (local) | Databases | pubs | Users there are two users, dbo (login = sa) and guest. I looked at the permissions for dbo and it had all the permissions for the except EXEC for the tables involved (authors, titles, and titleauthor).

2. Under (local) | Security | Logins there are three accounts: Administrator, my local windows account, and sa. They all have server access set to "permit".

So I don't know where to go from here.

I appreciate any help that anyone can offer.

Old February 8th, 2005, 03:07 PM
Registered User
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

I tried a different connection string (generated automatically by UI) and it worked:

    Dim objConnection As SqlConnection = New SqlConnection("workstation id=AARON;packet size=4096;integrated security=SSPI;data source=AARON;" & _
        "persist security info=True;initial catalog=pubs")

Now the only question is why??
Old February 8th, 2005, 05:55 PM
Registered User
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

I have an additional chapter 16 question:

I noticed that if I comment out the Open and Close for the objConnection, the fill still works. Code:

            objDataAdapter.Fill(objDataSet, "authors")

Why?? If Open and Close are not totally necessary then what are the pros and cons of using/not using Open and Close?
Old February 9th, 2005, 06:01 AM
Thearon's Avatar
Wrox Author
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts


The DataAdapter will automatically open and close the database connection for you. However, it is good coding practice to open and close the database yourself just before it is needed and right after you are finished with it.
Old October 24th, 2005, 06:13 PM
Registered User
Join Date: Oct 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts


Thanks for posting your Wizard-generated code. Unfortunately, I could only afford the Standard Edition, so when I try to create a connection (right-click on Database Connections in Server Explorer, Add connection...), it will let me test the connection, with success, but when I click on OK, I get a message box that says "It is only possible to connect to MSDE databases and Access databases with this version of Visual Studio."

That made me wonder if the reason I couldn't connect was because I couldn't afford $500 for the Professional Edition. Then I found your posts and copied your syntax (replacing workstation ID & Data Source). Presto! It worked!

Thanks for providing a solution.

OffByOne (Richard F. Johnson)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 16 Fig 16-11 krsouthern BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 1 July 8th, 2008 12:11 PM
Chapter 16 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 3 April 11th, 2005 11:01 AM
chapter 16 ?? farsfar2 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 11 March 26th, 2005 10:01 PM
Chapter 16 ioda006 JSP Basics 3 August 21st, 2004 07:28 PM
Help in Chapter 16 aldwincusi VB.NET 2002/2003 Basics 2 June 4th, 2003 09:52 AM

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