Link to home
Start Free TrialLog in
Avatar of Angie532
Angie532

asked on

Insert all the rows without errors into a database called pipeline.mdb

Hi Everyone I did a loop that checks the records from Excel for errors.  The records with errors go into an errors spreadsheet which I already did, but all the records without error need to be inserted into my database (pipeline.mdb)  
Can you guys help me with this?  Basically the entire row gets inserted into the database...I have an if statment that looks for the rows to be inserted but I don't know what code I can use to actually insert them...
Here's my code but of course it doesn't work.

for i = 1 to 14
    if (errors in the records)then 'pseudocode
    'put records into the excel spreadsheet --this part works, no problem
    Else
            'Database records without errors should be inserted into the database, I don't know how to do this?!?
             Dim RS As recordset
            Set CMD.ActiveConnection = Conn      
            CMD.CommandText = "INSERT * INTO COMPANY"
            CMD.CommandType = adCmdText
            CMD.Execute
    End If
Next i
ASKER CERTIFIED SOLUTION
Avatar of PSSUser
PSSUser
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cjard
cjard

or a simpler version:

the format of an insert command is:

INSERT INTO company (<comma delimited list of field names) VALUES (<comma demilited list of field values)


so the following:

INSERT INTO company (name,address,product) VALUES ("Microsoft","One Microsoft Way","software")