ACC: "Incorrect Syntax Near '-'" Using TransferDatabase Action

Last reviewed: May 20, 1997
Article ID: Q106244
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

When you are running a TransferDatabase macro action to attach a SQL Server table, the following error message may be generated:

   Connection Failed. SQL State 37000. SQL Server Error 102. Incorrect
   Syntax Near '-'.

NOTE: This behavior no longer occurs in Microsoft Access for Windows 95, version 7.0.

MORE INFORMATION

This error is generated because there is an error in the database name argument, or connect string, of the TransferDatabase macro action.

The Microsoft Access Help system suggests that the connect string can be copied from the table properties of the attached table. When you copy the connect string into the database name argument, a string similar to the following example is produced:

NOTE: In the following example, an underscore (_) is used as a line- continuation character. Remove the underscore when re-creating this example.

   ODBC;DSN=MyServer;UID=User2;APP=Microsoft Access;WSID=User2; _
   DATABASE=pubs-->-->dbo.authors

The syntax error is caused by the text after the "pubs" database name. All text after the database name should be removed from the string, and the table name should be moved to the source argument.

The following example demonstrates correct arguments for the TransferDatabase action:

   Transfer Type:  ATTACH.
   Database Type:  <SQL DATABASE>.
   Database Name:  ODBC;DSN=MyServer;UID=User2;APP=Microsoft Access; _
                      WSID=User2;DATABASE=pubs
   Object Type:    TABLE
   Source:         DBO.AUTHORS
   Destination:    DBO_AUTHORS
   Structure Only: NO


Additional query words: transfer
Keywords : kberrmsg kbusage OdbcOthr
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 20, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.