DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: SQL Insert help

  1. #1
    Join Date
    Sep 2004
    Northampton,United Kingdom

    SQL Insert help


    I need some advice with a database insert problem

    I have a product B & H 16's and when my user trys to add this item it kicks up a error -2147217900 so I trapped it and displayed "Band text"

    but how can I add the B & H 16's into the database?



  2. #2
    Join Date
    Sep 2004
    Northampton,United Kingdom
    I've sorted it

    thanks guys

    Replace(text1.text,"'", "''")

    Works wonders

  3. #3
    Join Date
    Mar 2009
    Italy - Breganze (VI)
    If you use Command with Parameters this problem doesn't exists!

    You can set the parameter value directly with control value, i.e.:

    parProduct.Value = txtProduct.Text
    parDate.Value = Now

    Using of parameters don't worry how value should be formatted, because the ADODB.Command pass the correct formatting automatically request by field Type for the specific database.

    a) Access require you pass formatted value #mydate# for Date type.
    b) SQLServer, Oracle, DB2, ... require you pass formatted value 'mydate' for Date type.

    So, if your software may to use different database type, or if you want migrate to Access to SQLServer, you has forced to change sintax for all queries to adjust formatting...

    Instead, if you use a Command, doesn't change any, because the statement
    parDate.Value = Now
    work for any database

    There are many others reason to use parameter, see here:
    Database - Why should I use Parameters instead of putting values into my SQL string?

Similar Threads

  1. insert into Access from SQL 2005
    By kafsar in forum VB Classic
    Replies: 6
    Last Post: 04-11-2009, 01:50 AM
  2. SQL Doubt (INSERT INTO)
    By biruel in forum VB Classic
    Replies: 5
    Last Post: 12-22-2007, 10:05 AM
  3. Problem in Insert Into Statement in SQL Server
    By priyamvada in forum Database
    Replies: 1
    Last Post: 03-07-2007, 06:13 AM
  4. Executing SQL Insert with ADO
    By Blake in forum VB Classic
    Replies: 3
    Last Post: 06-19-2002, 12:47 AM
  5. SQl Insert Into Statement
    By Sheryl Kemp in forum Database
    Replies: 0
    Last Post: 07-18-2001, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center