-
SQL Insert help
hi
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?
Thanks
Andy
-
I've sorted it
thanks guys 
Replace(text1.text,"'", "''")
Works wonders
-
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.
Example:
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?
http://www.vbforums.com/showthread.php?t=548787
Similar Threads
-
By kafsar in forum VB Classic
Replies: 6
Last Post: 04-11-2009, 01:50 AM
-
By biruel in forum VB Classic
Replies: 5
Last Post: 12-22-2007, 10:05 AM
-
By priyamvada in forum Database
Replies: 1
Last Post: 03-07-2007, 06:13 AM
-
By Blake in forum VB Classic
Replies: 3
Last Post: 06-19-2002, 12:47 AM
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|