C# OleDBException datatype not matched when copying table from MSSQL 2005 Express to MS Access 2016

Kay_Lee 101 Reputation points
2022-08-05T07:59:03.867+00:00

MS-SQL 2005 DataType CREATE TABLE consultation(Id int NOT NULL IDENTITY(1,1) PRIMARY KEY, person nvarchar(300), consultationid int, personname nvarchar(3000), visitdate DATETIME, phonenumber nvarchar(2000), consultation nvarchar(4000)

MS-Access 2016 DataType CREATE TABLE consultation([Id] int NOT NULL IDENTITY(1,1) PRIMARY KEY, [person] TEXT(50), [consultationid] int, [personname] TEXT(50), [visitdate] DATETIME, [phonenumber] TEXT(100), [consultation] LONGTEXT

I've created SQL2005 and Access2016 tables as above shown. And when I try to copy table from SQL 2005 to Access 2016 through C# OleDBCommand with making a DataTable, OleDBException datatype not matched is shown.

In case like this, what should I consider & fix ?

Many thanks for your kind excellence !

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,706 questions
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
821 questions
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 40,741 Reputation points
    2022-08-05T10:18:11.723+00:00

    but the actual data inside are smaller than 50.

    The data provider/components can't guess the may max size of the data in the source file.
    Table definition source+destination must (!) match.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 40,741 Reputation points
    2022-08-05T08:16:24.963+00:00

    person nvarchar(300) ... personname nvarchar(3000),
    [person] TEXT(50) ... [personname] TEXT(50),

    Now guess, why you get a mismatch error; the column sizes absolutly don't match.

    1 person found this answer helpful.