MySqlConnection con = new MySqlConnection("host=db4free.net;user=*;password=*;database=*;");
MySqlCommand xcmd = new MySqlCommand("SELECT x FROM members WHERE id='" + Login.idd + "';");
xcmd.Connection = con;
xint.Connection = con;
DataTable dt = new DataTable();
con.Open();
xcmd.ExecuteNonQuery();
int xx = (int)xcmd.ExecuteScalar();
xcmd.Connection.Close();;
xcmd.Dispose();
x = xx;
con.Close();
if (x == 2)
{
button6.BackgroundImage = Properties.Resources.logo;
}
我希望程序從數據庫中讀取X的值,它加入一個變量,然後如果它等於2,顯示標誌...C#DB列值
除了你的字符串連接的SQL注入問題,究竟是什麼問題?你不需要'DataTable'或'ExecuteNoneQuery'行。 – dash
和'xInt.Connection'是一個總括號... – Steve