|
-
Jun 2nd, 2003, 11:57 AM
#1
Thread Starter
Fanatic Member
add new record
I've created a database and a table with no records. How do I add a new record using ADO?
-
Jun 2nd, 2003, 12:46 PM
#2
Personal preference is using SQL statements. Say you have a table like (assuming you're using Access):
Code:
TableName
Field1 (Auto number)
Field2 (String)
Field3 (Numeric)
Inserting would be:
Code:
INSERT INTO TableName (Field2, Field3) VALUES ('ABC', 123)
The first set of parentheses specify the fields to insert into & the second the values. In this example, you have to specify the field names as the first field is autonumbered, and as such you can't specify the value to insert. Assuming that it wasn't autonumbered & was say numeric, you could forgo the field name list.
Next part, the values themselves. The second field (Field2) is a string. These values are prefixed & suffixed with single quotes - you'll get lovely errors if you don't use these. Now the third field, the numerics aren't prefixed & suffixed - again, you'll get lovely errors in Access if you treat numerics as strings.
Nice, short tutorial on inserts. I think maybe you should go play on google & search for SQL tutorials, as there's a helluva lot more to SQL than just inserting.
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
|
Click Here to Expand Forum to Full Width
|