Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# powershell下的csharp mysql编译错误CS0246_C#_Mysql - Fatal编程技术网

C# powershell下的csharp mysql编译错误CS0246

C# powershell下的csharp mysql编译错误CS0246,c#,mysql,C#,Mysql,我正试图编译一个简单的C#程序,在我的Windows10笔记本电脑上对MySQL数据库中的一个表进行选择。当我尝试在Developer PowerShell for VS 2019下使用以下命令编译代码时: csc mysql1.cs 我收到错误消息error CS0246:找不到类型或命名空间名称“MySql” 我在目录C:\Program Files(x86)\MySQL\MySQL Connector Net 8.0.18\Assemblys\v4.5.2下进行了检查,确实有文件MySQL

我正试图编译一个简单的C#程序,在我的Windows10笔记本电脑上对MySQL数据库中的一个表进行选择。当我尝试在Developer PowerShell for VS 2019下使用以下命令编译代码时:

csc mysql1.cs

我收到错误消息error CS0246:找不到类型或命名空间名称“MySql”

我在目录C:\Program Files(x86)\MySQL\MySQL Connector Net 8.0.18\Assemblys\v4.5.2下进行了检查,确实有文件MySQL.Data.dll

我在谷歌找到的所有文章都说我必须“添加一个参考”到我的项目中。我没有一个项目,这只是一个命令行编译

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace ConsoleApp1
{
    class Program
    {
    static void Main(string[] args)
    {
        Console.WriteLine("This is a MySQL Test");
        string mysql_info = "Persist Security Info=False;server=localhost;database=myschema;uid=root;password=mypassword";

MySql.Data.MySqlClient.MySqlConnection dbConn =
    new MySql.Data.MySqlClient.MySqlConnection(mysql_info);
MySqlCommand cmd = dbConn.CreateCommand();
cmd.CommandText = "SELECT user_id from hockey_users WHERE username ='someone'";

try
{
    dbConn.Open();                
} catch (Exception erro) {
    MessageBox.Show("Error" + erro);
    this.Close();
}

MySqlDataReader reader = cmd.ExecuteReader();

while (reader.Read())
{
    idnumber = reader.ToString();
    Console.WriteLine("id = " + idnumber);
}

    }
    }
}

根据我运行命令行编译时显示的标题,我使用的编译器是:Microsoft(R)Visual C#编译器版本4.8.3752.0 for C#5I尝试添加“/引用”选项,但我收到了许多新的错误消息:错误CS0103:当前错误CS0026中不存在名称“MessageBox”:关键字“this”在静态属性中无效,静态方法或静态字段初始值设定项您在visual studio中使用它,但在csc中您必须添加引用请参见我尝试向compile命令添加“/reference”选项,但这导致出现不同的错误(请参见我以前的注释)。我重新运行visual studio社区安装程序以升级到最新版本。我还要求为C#编译器提供额外的东西(罗西伦的名字被列出了?),我仍然看到同样的错误消息