我已经将这个CS0246错误追赶了几个小时,并且不确定如何解决它。给出以下简单的C#代码:
using System;
// using Microsoft.Data.Odbc;
using System.Data.Odbc;
namespace dotnetdb
{
class Program
{
static private void SelectRows(string[] args)
{
string passWord = "PWD=password";
string uName = "UID=username";
string dbServer = "SERVER=server";
string dbName = "DATABASE=db";
string driver = "DRIVER={ODBC Driver 13 for SQL Server}"
string connString = // assembled from above
string sql = // sql;
OdbcConnection conn = new OdbcConnection(connString);
conn.Open();
OdbcCommand cmd = new OdbcCommand(sql, conn);
// work with cmd
Console.WriteLine("Didnt kick the bucket!");
}
}
}
第Microsoft2行上的节产生一个CS0234错误。第3行上的节(来自Microsoft文档)为我提供了CS0246:
Program.cs(20,13): error CS0246: The type or namespace name 'OdbcConnection' could not be found
我一直在go和python中使用此ODBC连接,但这是我第一次尝试将其与C#一起使用。也是我的第一个C#程序。上面的代码几乎直接从MS文档中删除-我缺少什么?如何获得访问权限System.Data.Odbc?
在学习如何使用C#之前,我是否要尝试跑步?
请注意,使用dotnet build [console|webapi]构建和运行创建的应用程序运行良好。
谢谢!
相关分类