2017-03-04 28 views
-1

我不能使用Syetem.Data.SqlClient。如何從Visual Studio代碼使用數據庫(c#)

這是我的代碼

using System; 
using System.Data.SqlClient; // <== error 

namespace ConsoleApplication 
{ 
    public class Program 
    { 
     public static void Main(string[] args) 
     { 
      Console.WriteLine("Hello World!"); 
     } 
    } 
} 

我使這個項目從控制檯,輸入「DOTNET新」和恢復。

我做了什麼?

+0

這可能對您有用。 http://stackoverflow.com/questions/35545346/asp-net-core-could-not-load-system-data-sqlclient –

+0

什麼是錯誤說? –

回答

1

您是否將「System.Data.dll」添加到您的項目參考中?

0

爲項目引用中的SQL服務器數據添加引用。如果沒有這個選項,那麼運行visual studio的選項選擇選項修改然後選擇SQL數據選項並運行設置。

相關問題