Fill a Dataset

I am trying to start using ADO.Net but I can't even fill a dataset.  I am getting an error "Incorrect Syntax near User" using the following code:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Imports System.Data.SqlClient
Imports System.Windows.Forms

Module Module1

    Sub Main()
        Dim cmdUser As SqlCommand
        Dim da As New SqlDataAdapter
        Dim conn As New SqlConnection
        Dim ds As New DataSet

        Try
            ' Configure the Connection
            conn.ConnectionString = "Data Source=(Local)\SQLExpress;Initial Catalog=BTBRepIT;Integrated Security=True;Pooling=False"

            ' Configure the Command
            cmdUser = conn.CreateCommand
            cmdUser.CommandText = "Select * From User"
            cmdUser.CommandType = CommandType.Text
            da.SelectCommand = cmdUser

            ' Fill the Dataset
            da.Fill(ds)

            MessageBox.Show("Completed Successfully")
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

End Module

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I know the problem isn't the SQL statement since they don't get much simpler than that but as far as what the actual problem is I have no idea.  Thank you in advance for your help.
LVL 3
kmcbreartyAsked:
Who is Participating?
 
bchoorConnect With a Mentor Commented:
try this

"SELECT * FROM [User]"

or

"SELECT * FROM ""User"""

HTH
~BC
0
 
bchoorCommented:
BTW, USER is a reserved word for sql - so that's why you may be having that problem.
0
 
kmcbreartyAuthor Commented:
Thank you,  that was the problem.  I usually precede my tables with tbl to aviod naming conflicts but was just creating a test to verify I was doing it correctly.
0
All Courses

From novice to tech pro — start learning today.