如何使用 XAMPP 数据库和 C# 创建登录表单?


string query = "SELECT * FROM staff";
string mySQLConnectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=workshopdb;sslmode=none";

MySqlConnection databaseConnection = new 
MySqlConnection(mySQLConnectionString);
MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection);
databaseConnection.Open();
MySqlDataReader myReader = commandDatabase.ExecuteReader();
if (myReader.HasRows)           //checks whether the table is empty
{
while (myReader.Read())     //reads rows consequently
{
MessageBox.Show(myReader.GetString(0) + " " + myReader.GetString(1) + " " + myReader.GetString(3));
//get strings(x) are columns of the table in the db
}
}
databaseConnection.Close();
}

我使用了此代码,但它无法识别我输入的用户名和密码。它不是识别输入的用户,而是显示数据库中的所有用户。

在 C# 中,构建平台是 .NET。大多数时候,我们可以将 MSSQL 用于数据库活动。要进行配置,我们可以使用 MSSQL Server Express。XAMPP运行在Apache服务器上。但是对于.NET开发,我们需要IIS服务器。在你这边,冲突出现了。做更多的研究,看看你在做什么,了解依赖的技术

最新更新