Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 8th, 2005, 01:30 PM
Registered User
 
Join Date: Feb 2005
Location: Southfield, MI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 16 Question

Hi,

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.

Thanks,
Aaron
  #2 (permalink)  
Old February 8th, 2005, 03:07 PM
Registered User
 
Join Date: Feb 2005
Location: Southfield, MI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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??
  #3 (permalink)  
Old February 8th, 2005, 05:55 PM
Registered User
 
Join Date: Feb 2005
Location: Southfield, MI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:

            'objConnection.Open()
            objDataAdapter.Fill(objDataSet, "authors")
            'objConnection.Close()

Why?? If Open and Close are not totally necessary then what are the pros and cons of using/not using Open and Close?
  #4 (permalink)  
Old February 9th, 2005, 06:01 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Aaron,

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.
  #5 (permalink)  
Old October 24th, 2005, 06:13 PM
Registered User
 
Join Date: Oct 2005
Location: Plano, TX, Afghanistan.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Aaron:

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)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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



All times are GMT -4. The time now is 04:56 PM.


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