Wrox Programmer Forums
|
BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
This is the forum to discuss the Wrox book Beginning Microsoft Visual Basic 2008 by Thearon Willis, Bryan Newsome; ISBN: 9780470191347
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 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 October 4th, 2009, 02:42 AM
Registered User
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 17, pls help

Hi, i need some help. I still new in programing (just start about a month ago).
I design a form that almost same as in Try It Out pg 581 so i just copy and paste the program and modify the connection. I also design my own sql database (using Microsoft SQL Server Express Edition with Advanced Services) and named it employees.mdf. I get an error "Incorrect syntax near the keyword 'user'" in this command line: objDataAdapter.Fill(objDataSet, "user"). user is my table in my databse. Here is the program:

Code:
' Import Data and SqlClient namespaces...
Imports System.Data
Imports System.Data.SqlClient

Public Class User
    ' Declare objects...
    Dim objConnection As New SqlConnection _
    ("server=localhost\SQLExpress;database=employees;user id=MUGEN86;password=******;")
    Dim objDataAdapter As New SqlDataAdapter( _
    "SELECT empid, dept, fname, lname, vehmodel,plateno, hpone, email, address, city, state, zip, datereg, tagid" & _
    "FROM user " & _
    "JOIN employ ON user.empid = employ.empid " & _
    "ORDER BY empid,lname,fname", objConnection)
    Dim objDataSet As DataSet
    Dim objDataView As DataView
    Dim objCurrencyManager As CurrencyManager

    Private Sub FillDataSetAndView()

        ' Initialize a new instance of the DataSet object...
        objDataSet = New DataSet()
        ' Fill the DataSet object with data...
        objDataAdapter.Fill(objDataSet, "user")
        ' Set the DataView object to the DataSet object...
        objDataView = New DataView(objDataSet.Tables("user"))
        ' Set our CurrencyManager object to the DataView object...
        objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)


    End Sub
 
Old October 4th, 2009, 04:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at this:
Code:
datereg, tagid" & _
    "FROM user " & _
Note how you concatenate FROM and tagid.... without a space so it ends up as tagidFROM when executed. Add a space after tagid or before FROM:

Code:
datereg, tagid " & _
    "FROM user " & _
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 5th, 2009, 06:42 AM
Registered User
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, thanks for the reply.
I do as you tell me but i still get the same error.
Did i make mistake with my database connection?
 
Old October 5th, 2009, 07:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Try assigning your SQL statement to a string variable before you send it to the constructor of the SqlDataAdapter and then watch its contents in the debugger. Then copy the SQL statement and try running it against your database directly. Maybe that sheds some light?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Errata Chapter 17 sahyouni ASP.NET 2.0 Professional 1 July 9th, 2009 06:07 AM
Chapter 17 HenzFast BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 2 April 14th, 2009 03:28 AM
Chapter 17 First Try It Out paloyme BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 7 August 23rd, 2006 11:14 AM
Chapter 17 first Try It Out paloyme Visual Basic 2005 Basics 0 April 17th, 2006 04:34 AM
Chapter 17 Gaby BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 September 8th, 2005 11:50 AM





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