I am writing from Navision to a SQL Database using ADO 2.8. I can do this using ADOConnection.Execute but would like to do this using ADOCommand.Execute. Does anyone know how to instantiate the command object?
By the way ADOCommand.ActiveConnection := ADOConn.State; does not work.
Also what is the fastest way to insert records into SQL with ADO? Do I use ADORecordset.AddNew, ADOCommand.Execute(with an insert into query) or some other method?
Hi, Sorry took so long to get back to you went on a last minute trip.
RecordsAffected := 0;
// Command Option Values:
// adCmdFile : 256 = Evaluate as a previously persisted file
// adCmdStoredProc : 4 = Evaluate as a stored procedure
// adCmdTable : 2 = Have the provider generate a SQL query and return all rows from the specified table
// adCmdTableDirect : 512 = Return all rows from the specified table
// adCmdText : 1 = Evaluate as a textual definition
// adCmdUnknown : 8 = The type of the CommandText parameter is unknown
// adCmdUnspecified : -1 = Default, does not specify how to evaluate
Options := 1;
IF ADOConnection.State = 1 THEN BEGIN
IF CurrentDB = ‘’ THEN
CurrentDB := GetCurrentDB;
ADOConnection.DefaultDatabase(CurrentDB);
ADOConnection.CommandTimeout(0); // Timeout set to indefinitely
ADOConnection.Execute(Statement,RecordsAffected,Options);
END ELSE
ERROR(Text002);