|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

February 10th, 2005, 06:02 PM
|
|
Registered User
|
|
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try it out:Ch 16 Dataset Example
Help!
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
Try
objConnection.Open()
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"
log.WriteEntry(errorMessages)
Console.WriteLine("An exception occurred. Please contact your system administrator.")
End Try
objDataAdapter.Fill(objDataset, "authors")
objConnection.Close()
grdAutherTitles.DataSource = objDataset
grdAutherTitles.DataMember = "authors"
objDataAdapter = Nothing
objConnection = Nothing
|

August 28th, 2009, 08:00 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Location: Orpington, Kent, United Kingdom.
Posts: 51
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |