简体   繁体   English

在 C# 中通过 ADO.Net 导入 Excel

[英]Excel import through ADO.Net in C#

Anybody please help me I am unable to import Excel file data in SQL Server Database .任何人都请帮助我我无法在SQL Server Database导入 Excel 文件数据。 The excel file data is in multi languages the data which is in English is uploaded properly but the data which is in other language is readed but in an encoded format. excel文件数据是多语言的,英文的数据正常上传,其他语言的数据被读取,但是是编码格式。

Please, let me know how can I import multi language excel file in database?请让我知道如何在数据库中导入多语言excel文件?

Not sure about collation used for datatable in SQL server.不确定用于 SQL Server 中数据表的collation You may need to update data type for imported data table in SQL server to support different encodings.您可能需要更新 SQL Server 中导入数据表的数据类型以支持不同的编码。 Make use of nvarchar data type for column for which different language input expected.对需要不同语言输入的列使用nvarchar数据类型。

You can do on non primary key fields:您可以对非主键字段执行以下操作:

ALTER TABLE [TableName]
ALTER COLUMN [ColumnName] nvarchar(N) null

On the primary key fields it will not work - you will have to recreate the table.在主键字段上它不起作用 - 您必须重新创建表。

Make sure that the length doesn't exceed 4000 since the maximum for VARCHAR is 8000 while NVARCHAR is only 4K确保长度不超过 4000,因为VARCHAR的最大值是 8000 而NVARCHAR只有 4K

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM