如何在没有oledb连接的情况下将数据从Excel导入到asp.net c#中的sql数据库 [英] how to import data from an excel to sql database in asp.net c# with out oledb connection

查看:47
本文介绍了如何在没有oledb连接的情况下将数据从Excel导入到asp.net c#中的sql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Excel中的数据从asp.net c#中的excel导入到sql数据库中,而在webconfig中没有oledb连接字符串

how to import data from an excel to sql database in asp.net c# with out oledb connection string in webconfig

推荐答案

您需要知道要插入的位置记录.为此,您需要具有连接字符串(基本上是db信息).如果您不想在web.config中拥有它,则可以在.cs文件本身中拥有它.
也许此链接会为您提供帮助.
从Excel导入SQL数据 [
You need to know where you are inserting records. For that you need to have the connection string (basically db information). If you don''t want to have it in web.config, then you have it in the .cs file itself.
Perhaps this link would help you.
SQL Import Data from Excel[^]


使用openrowset选项:

Using openrowset option :

select * into #temp_table
    from openrowset
    (
        'Microsoft.Jet.OLEDB.4.0',
        'Excel 8.0;Database=C:\Useless\Temp\sample.xls',
        [Customer_Account_Details


);




运行查询时,请确保您的Excel文件实际上已关闭,否则将收到提供程序错误,并且该文件的路径是相对于服务器的.




Please make sure that your Excel file is actually closed when you run the query or otherwise you will receive provider error, and the path to the file is relative to the server.


这篇关于如何在没有oledb连接的情况下将数据从Excel导入到asp.net c#中的sql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆