我对SQL完全是新手,想用数据库制作一个ConsoleApp。我了解了一些内容并尝试了一下。当我需要创建SqlConnection时,我的VS 2019 Preview显示了以下错误:
严重性 代码 说明 项目 文件 行 抑制状态 错误 CS1069 The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly. ConsoleApp1 C:\Users\User\Desktop\Bald Code\ConsoleApp1\ConsoleApp1\Program.cs 12 Active
我不明白为什么它无法工作。
这是我的代码:
using System;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string connectionString;
SqlConnection cnn;
}
}
}