无法连接到C#中的csvfile - Oledb适配器 [英] Fail connection to csvfile in C# - Oledb adapter

查看:124
本文介绍了无法连接到C#中的csvfile - Oledb适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我发疯了:



当我按下一个按钮时,我想用C#连接一个CSV,当事件发生时字符串连接报告错误,没有发现路径,我不知道为什么。我谷歌但仍然有麻烦。我尝试使用下一种格式,但它们不起作用:



a)



This is driving me crazy:

I want to connet a CSV in C# when I press a button and the string connection reports error when the event happens , no path found, I don't know why. I google it but still having troubles. I try with next formats and they don't works:

a)

string PATH = "C:\\Users\\xxx\\Documents\\Visual Studio 2013\\Projects\\tt\\tt\\Data\\";
string sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PATH + ";Extended Properties=\"text;HDR=yes;FMT=delimited\";";









b)







b)

string sConnection =    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\\Users\xxx\\Documents\\Visual Studio 2013\\Projects\\xx\\xx\\Data\\employees.csv;Extended Properties=\"text;HDR=YES;FMT=Delimited\"";





c)





c)

string PATH = "C:\\Users\xxx\\Documents\\Visual Studio 2013\\Projects\\xx\\xx\\Data\\employees.csv;";
            string sConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=+PATH+;Extended Properties="Excel 12.0;HDR=YES";"







哪里是我的错误或我错过了什么?




where is my mistake or what am i missing?

推荐答案

你应该只通过尝试读取.csv文件时的目录名称。请参阅使用OleDb导入文本文件(选项卡,CSV,自定义) [ ^ ]了解更多详情。
You should only pass the directory name when trying to read .csv files. See Using OleDb to Import Text Files (tab, CSV, custom)[^] for more details.


您好



请点击以下链接



http://www.connectionstrings.com/textfile/ [ ^ ]





http://stackoverflow.com/问题/ 6813607 / parsing-csv-using-oledb-using-c-sharp [ ^ ]
Hello

follow the below link

http://www.connectionstrings.com/textfile/[^]


http://stackoverflow.com/questions/6813607/parsing-csv-using-oledb-using-c-sharp[^]


这篇关于无法连接到C#中的csvfile - Oledb适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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