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

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
Issue type : kbinfo


Last Reviewed: March 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.