[HY104] [ Microsoft Access Driver] [OdbcEexcption]
I have configured an OdbcDataAdapter which I want to be able to connect to
either an Access Database or an SQL Server Database. Of course the Databases
are having the same DB schema, except on sligh diffence: As I want to
support large text fields ( > 255 characters ), I am using Memo fields on
Access and varchar(8000) fields on SQL for certain fields.
Since the SQL-statements were generated by the DataAdapter Configuration
Wizard using the connection to the SQL Server Database, I am modifying them
during runtime if the Access version is connected:
After the connection was opened, I am querying for the OdbcConnection.Driver
property. If I found out that the Access DB was connected I am modifying the
OdbcParameters of the commands associated with the Dataadapter. For all the
OdbcParameters which are referring to the "large Textfields", I am setting
the OdbcParameter.Size property to 2147483647 and the OdbcParameter.OdbcType
to System.Data.OdbcType.NVarChar which I have found through experimentation
seem to be the right settings for Access Memo fields. Unfortunately I am
still getting an OdbcException while adding / updating data to the Table:
System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][Odbc Microsoft
Access Driver] Invalid Precision
This seems to be related to wrong parameters for the commands.
Any ideas on how to best establish the goal of supporting Access and SQL
Server in this case would be very welcome!
one solution:
Using memo in Asscss , OdbcType.NVarChar of OdbcType.Text OdbcParameter
either an Access Database or an SQL Server Database. Of course the Databases
are having the same DB schema, except on sligh diffence: As I want to
support large text fields ( > 255 characters ), I am using Memo fields on
Access and varchar(8000) fields on SQL for certain fields.
Since the SQL-statements were generated by the DataAdapter Configuration
Wizard using the connection to the SQL Server Database, I am modifying them
during runtime if the Access version is connected:
After the connection was opened, I am querying for the OdbcConnection.Driver
property. If I found out that the Access DB was connected I am modifying the
OdbcParameters of the commands associated with the Dataadapter. For all the
OdbcParameters which are referring to the "large Textfields", I am setting
the OdbcParameter.Size property to 2147483647 and the OdbcParameter.OdbcType
to System.Data.OdbcType.NVarChar which I have found through experimentation
seem to be the right settings for Access Memo fields. Unfortunately I am
still getting an OdbcException while adding / updating data to the Table:
System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][Odbc Microsoft
Access Driver] Invalid Precision
This seems to be related to wrong parameters for the commands.
Any ideas on how to best establish the goal of supporting Access and SQL
Server in this case would be very welcome!
one solution:
Using memo in Asscss , OdbcType.NVarChar of OdbcType.Text OdbcParameter
浙公网安备 33010602011771号