Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 10th, 2005, 06:02 PM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Try it out:Ch 16 Dataset Example


I am going through the book and I am working with a microsoft SQL server 2000.

I get an error when I try to run the DataSet Example but only when I try to use the JOIN command. If I leave that out, it runs fine. What am I doing wrong?:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objDataAdapter.SelectCommand = New SqlCommand
        objDataAdapter.SelectCommand.Connection = objConnection

        objDataAdapter.SelectCommand.CommandText = "SELECT au_lname, au_fname, title, price " & _
     "FROM authors " & _
     "JOIN titleauthor ON authors.au_id = titleauthor.au_id " & _
     "JOIN titles ON titleauthor.title_id = titles.title_id " & _
     "ORDER BY au_lname, au_fname"

        objDataAdapter.SelectCommand.CommandType = CommandType.Text

        Catch b As SqlException
            Dim errorMessages As String
            Dim i As Integer

            For i = 0 To b.Errors.Count - 1
                errorMessages += "Index #" & i.ToString() & ControlChars.NewLine _
                               & "Message: " & b.Errors(i).Message & ControlChars.NewLine _
                               & "LineNumber: " & b.Errors(i).LineNumber & ControlChars.NewLine _
                               & "Source: " & b.Errors(i).Source & ControlChars.NewLine _
                               & "Procedure: " & b.Errors(i).Procedure & ControlChars.NewLine
            Next i

            Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog
            log.Source = "My Application"
            Console.WriteLine("An exception occurred. Please contact your system administrator.")
        End Try

        objDataAdapter.Fill(objDataset, "authors")
        grdAutherTitles.DataSource = objDataset
        grdAutherTitles.DataMember = "authors"

        objDataAdapter = Nothing
        objConnection = Nothing

Old August 28th, 2009, 07:00 AM
Authorized User
Join Date: Jun 2006
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Default Leaving 'JOINS' out of SELECT Statement ?

If you have copy of Access, or the Microsoft database generator in VB 2008 ( SQL SERVER or whatever ) try using the design wizard to generate the S.Q.L. then copy and paste it into the program at the appropriate point. Make sure it generates the desired output in the wizard firstly. Sometimes there are slight differences in the syntax of S.Q.L. commands as expected, and that which works e.g. '%' has now replaced '*' as a 'wild-card' character when using the LIKE clause in S.Q.L. Good luck, if anything's not clear, reply to this.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 16 -- compile error w/ components adidaswood BOOK: Beginning ASP.NET 1.0 0 September 22nd, 2004 08:57 PM
Chapter 16, DataSet Example danascmitz VB.NET 2002/2003 Basics 6 January 5th, 2004 05:11 AM
DataSet example, Chapter 16 jtimms BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 13 October 11th, 2003 05:03 PM
Ch 16 driver not found dmswdev JSP Basics 1 June 27th, 2003 05:15 AM

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