我与我的数据库建立了连接,并且我已经执行了一个查询以获取我的表的特定字段的结果,但是读者没有输入,为什么?
public void connect()
{
string connStr = @"Server=xx98.66;Port=xx6;Database=sxxt;Uid=axx;Pwd=admxxx3z;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();
string stm = "SELECT lastUpdated from soccerseason WHERE caption = 'Eredivisie 2015/1'";
MySqlCommand cmd = new MySqlCommand(stm, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine("stdrstrr" + rdr.GetString(0));
}
Console.WriteLine("Connection successfull !");
conn.Close();
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Eccezione => " + ex.ToString());
}
Console.WriteLine("Done.");
}
}
答案 0 :(得分:0)
这对我有帮助
包括此
WebSecurity
稍微更改代码并检查
using MySql.Data.Common;
using MySql.Data.Types;
using MySql.Data.MySqlClient;