System.Data.OleDB不存在! [英] System.Data.OleDB doesnt exist!
问题描述
使用System.Data; //使用System.Data.OleDB存在
; //无法找到
using System.Data; // exist
using System.Data.OleDB; // cant find
我一直在尝试添加引用和其他方法,但仍然无法连接它。怎么了? (Visual Studio 2017)
I have been trying add reference and other ways, but still cant connect it. What is wrong? (Visual Studio 2017)
VS建议仅使用System.Data.Common和System.Data.SqlTypes;请帮帮我。
VS suggests only System.Data.Common and System.Data.SqlTypes; Help me please.
推荐答案
嗨AndrewButko,
Hi AndrewButko,
感谢您在此发帖。
你能提供你的代码吗?
我使用下面的代码在Visual Studio 2017上进行测试。我可以使用System.Data.OleDB添加引用。
I test on the Visual Studio 2017 with the code below. I could add reference with System.Data.OleDB.
public void ReadMyData(string connectionString)
{
string queryString = "SELECT OrderID, CustomerID FROM Orders";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetString(1));
}
// always call Close when done reading.
reader.Close();
}
}
以下是有关System.Data.OleDB的MSDN文档供您参考。
Here is the MSDN documents about System.Data.OleDB for your reference.
最诚挚的问候,
Wendy
这篇关于System.Data.OleDB不存在!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!