Microsoft KB Archive/106244

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

Article ID: 106244

Article Last Modified on 5/6/2003

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q106244



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: . 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 kbinfo kbusage KB106244

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.