Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:47:26+00:00 2026-06-03T08:47:26+00:00

Just to let you know this is my first question im posting on this

  • 0

Just to let you know this is my first question im posting on this website, so please if I’ve missed anything just let me know. The problem im having is this, when the program runs im getting the following error message

Syntax error in FROM clause

The code is here

    Dim dbProvider As String
    Dim dbSource As String
    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim MaxRows As Integer
    Dim sql As String
    Dim TableName As String
    Dim TableCreate As New OleDb.OleDbCommand("CREATE TABLE [" & TableName & "](" & "ID INTEGER NOT NULL," & ")", con)
    Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM  [" & TableName & "]", con)
    Dim cb As New OleDb.OleDbCommandBuilder(da)

    TableName = TbTableName.Text

    dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbSource = "Data Source = E:\A2 Computing\Project\PasswordDatabase.mdb"

    con.ConnectionString = dbProvider & dbSource

    con.Open()

    da.Fill(ds, "NewTable")

    MaxRows = ds.Tables("NewTable").Rows.Count

The Problem im having is at this line

    da.Fill(ds, "NewTable")

Im not sure what I’ve missed out, Im guessing its something to do with the brackets when I declare tablecreate or da? =S Any help would be greatly appreciated. =)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:47:28+00:00Added an answer on June 3, 2026 at 8:47 am

    You need to assign something to TableName before you use it, not after. Your current SQL is SELECT * FROM [], which is why you’re getting a syntax error there.

    Change the order of your code:

    Dim TableName As String
    TableName = TbTableName.Text
    
    Dim TableCreate As New OleDb.OleDbCommand("CREATE TABLE [" & TableName & "](" & _
       "ID INTEGER NOT NULL" & ")", con)
    Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM  [" & TableName & "]", con)
    Dim cb As New OleDb.OleDbCommandBuilder(da)
    

    You also need to execute the TableCreate statement. IIRC, you use ExecuteNonQuery to do so.

    TableCreate.ExecuteNonQuery;
    

    Your table create SQL could be simplified, BTW:

    ' Remove unnecessary concatenation for column definition, as it's always
    ' the same
    Dim TableCreate As New OleDb.OleDbCommand("CREATE TABLE [" & TableName & _
      "](ID INTEGER NOT NULL)", con)
    

    Where are you actually connecting to the database? I don’t see an OleDBConnection anywhere in your code?

    Here’s a full example from the MSDN documentation for OleDBCommand.ExecuteNonScalar:

    Private Sub CreateOleDbCommand( _
          ByVal queryString As String, ByVal connectionString As String)
      Using connection As New OleDbConnection(connectionString)
        connection.Open()
        Dim command As New OleDbCommand(queryString, connection)
        command.ExecuteNonQuery()
      End Using
    End Sub
    

    Also, you are aware that doing a CREATE TABLE creates a new, empty table, and therefore your SELECT * FROM it won’t return anything but a single NULL row because you’re not inserting any data?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me preface this question. I have just started using jquery, so please be
First, I acknowledge the possibility that this question could be a duplicate; just let
First of all, i'm a Graphic designer so please ignore if this programming question
The Disclaimer First of all, I know this question (or close variations) have been
First, I know this question has been asked several times before and that in
Just a quick question about best practice in MVC development. Let's say that I've
Let me first put the code snippets here. I am just using the ASP.NET
I know this is more heavy question, but I think its interesting too. It
Important: This question is getting quite long, if this is the first time you're
First, I am super-new to Objective-C/iOS development and, in fact, this question is for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.