Ive been chasing this CS0246 error for a couple hours and am not sure how to resolve it. Given this simple C# code:
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!");
}
}
}
The Microsoft
stanza on line 2 yields a CS0234
error. The stanza on line 3 (from the Microsoft docs) gives me the CS0246:
Program.cs(20,13): error CS0246: The type or namespace name 'OdbcConnection' could not be found
I use this ODBC connection in go and python all the time but this is my first attempt at using it with C#. Also my first ever C# program. The code above is scraped almost directly from the MS docs - what am I missing? How do I get access to System.Data.Odbc
?
Am I trying to run before I learn how to walk with C#?
Note that applications created with dotnet build [console|webapi]
build and run just fine.
Thanks!