Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C语言中的OldeDb对象异常#_C#_Oledb - Fatal编程技术网

C# C语言中的OldeDb对象异常#

C# C语言中的OldeDb对象异常#,c#,oledb,C#,Oledb,此异常最初是在此调用堆栈中引发的: 使用Microsoft.ACE.OLEDB.12.0或Microsoft.ACE.OLEDB.16.0而不是Microsoft.Jet.OLEDB.4.0。打开CSV文件时,连接字符串包含目录路径,而不是.CSV文件名,扩展属性不指定Excel 8.0,而是指定text。查询SELECT*FROM,指定文件名,而不是像这样的类似Excel的工作表[9-50070\u 000018.csv$]+(更多问题)--看不同的例子,你能写一个正确的陈述吗?我已经按照你给

此异常最初是在此调用堆栈中引发的:


使用
Microsoft.ACE.OLEDB.12.0
Microsoft.ACE.OLEDB.16.0
而不是
Microsoft.Jet.OLEDB.4.0
。打开CSV文件时,连接字符串包含目录路径,而不是.CSV文件名,扩展属性不指定
Excel 8.0
,而是指定
text
。查询
SELECT*FROM
,指定文件名,而不是像这样的类似Excel的工作表
[9-50070\u 000018.csv$]
+(更多问题)--看不同的例子,你能写一个正确的陈述吗?我已经按照你给定的链接进行了操作,但仍然发现连接错误。open你能用记事本打开文件吗?文件中的数据最近有变化吗?您最近是否进行过任何windows更新?我已将连接字符串更改为Jimi Guidence。现在,我遇到无效路径错误,因为我的路径是正确的。
System.Data.OleDb.OleDbConnectionInternal.OleDbConnectionInternal(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.OleDbConnection)
    System.Data.OleDb.OleDbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection)
    System.Data.ProviderBase.DbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionPoolGroup, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal, out System.Data.ProviderBase.DbConnectionInternal)
    System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionInternal.OpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory)
    System.Data.OleDb.OleDbConnection.Open()
    WindowsFormsApp1.DB_Connect.DB_Fields() in DB_Connect.cs
    ...
    [Call Stack Truncated]
public static string[] DB_Fields()
{

String[] s = new string[21];
int i = 0, res1;
string s1 = "-";

            string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Mu\Desktop\9-50070_000018.csv;" + @"Extended Properties='Excel 8.0;HDR=No;'";
            using (OleDbConnection connection = new OleDbConnection(con))
            {
                connection.Open();
                OleDbCommand command = new OleDbCommand("select * from [9-50070_000018.csv$]", connection);
                using (OleDbDataReader dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var data = dr[0];
                        //Console.WriteLine(data);
                        res1 = Strings.InStr(data.ToString(), s1, CompareMethod.Text);
                        //MessageBox.Show(res1.ToString());
                        //MessageBox.Show(data.ToString());
                        if (res1 == 0)
                        {
                            s[i] = data.ToString();
                            i++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return s;
        }