[AccessD] ADO insert command

Rusty Hammond rusty.hammond at cpiqpc.com
Wed Feb 17 10:33:01 CST 2010


Doug,

Try taking the semicolon off the end of the statement.  I know Microsoft
SQL doesn't use them and I'm guessing MySQL doesn't either.  I've only
seen it used in Access SQL.

HTH

Rusty 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Steele
Sent: Tuesday, February 16, 2010 6:46 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] ADO insert command

Hello All:

I have some code which connects to a MySQL database.  Simply Accounting,
in this case - they have changed their back end to MySQL from Access.

Now I want to run an insert query to grab some data from Simply.  Here's
my
code:

Public Sub ImportSimplyTables(conn As ADODB.Connection)
  Dim rs As ADODB.Recordset
  Dim Cmd As String

  Cmd = "INSERT INTO taccountx ( lId, dYtc ) SELECT tAccount.lId,
tAccount.dYtc FROM tAccount;"
  conn.Execute Cmd, , adCmdText + adExecuteNoRecords

End Sub

I've tried various combinations of adCmdText, adExecuteNoRecords, etc.
but nothing seems to work.  The Execute runs but no records are added to
my table taccountx.  I know that the connection is opened correctly; if
I create an ADO recordset from the tAccount table I can read it and the
fields are present and have data.

Any suggestions?  Thanks,

Doug
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
**********************************************************************
WARNING: All e-mail sent to and from this address will be received,
scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc.
corporate e-mail system and is subject to archival, monitoring or review 
by, and/or disclosure to, someone other than the recipient.
**********************************************************************




More information about the AccessD mailing list