dcsimg
Results 1 to 7 of 7

Thread: DataBase insert

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    75

    DataBase insert

    i have problem with inserting data to table if the table name like "84848" Numbers i get error
    But if the table name is like "datausers" letters so the problem is when the table name is from number doesn't work
    and my codes is

    Dim sqlstatament As String = "INSERT INTO" & Label1.Text & " (Price) VALUES ('" & TextBox1.Text & "')"
    savedata(sqlstatament)

    What should i solve here to let it works

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,272

    Re: DataBase insert

    you cant have a table with a name of just numbers. just dont do it. there is usually not even a need for any numbers in a table name i'd say.

  3. #3
    Member
    Join Date
    Jul 2017
    Location
    Exeter, UK
    Posts
    58

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,788

    Re: DataBase insert

    Using just digits in a table name may be illegal in some databases but, if it's legal, you'd certainly have to escape the name, e.g. wrap it in brackets. That said, I have to agree with digitalShaman that you really shouldn't do it. I've rarely encountered a good reason to use any digits in a table name and I can't imagine that there is a good reason to use all digits.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Fanatic Member
    Join Date
    Sep 2017
    Posts
    548

    Re: DataBase insert

    If you seen the table names that "BAAN" produces, you would all vomit, and once you cleaned yourself up from that and opened a table to see the column names you would probably just turn it off.

  6. #6
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    6,926

    Re: DataBase insert

    If you seen the table names that "BAAN" produces
    Been there, done that, had to clean my T-Shirt.

    What JMc said is correct but it's probably not "brackets". Different databases use different delimiters but it's most likely that you'll need either square brackets (yes, I appreciate this is a subset of "brackets"): Insert into [1234] or quotes: Insert into "1234". If you tell us what database you're using we'll be able to tell you for certain.

    I think there are sometimes reasons to use a number as part of a table name but I've never wanted to use it as the whole table name. The table name should describe the contents of the table, e.g. "Orders", "Customers", "Tax Returns".
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  7. #7
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    6,926

    Re: DataBase insert

    If you seen the table names that "BAAN" produces
    Been there, done that, had to clean my T-Shirt.

    What JMc said is correct but it's probably not "brackets". Different databases use different delimiters but it's most likely that you'll need either square brackets (yes, I appreciate this is a subset of "brackets"): Insert into [1234] or quotes: Insert into "1234". If you tell us what database you're using we'll be able to tell you for certain.

    I think there are sometimes reasons to use a number as part of a table name but I've never wanted to use it as the whole table name. The table name should describe the contents of the table, e.g. "Orders", "Customers", "Tax Returns".
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width