using MySql.Data.MySqlClient;//安裝MySql.Data.msi套件,再引用參考 //資料庫位址,帳號,密碼,資料庫名稱,存取編碼 MySqlConnection myConnection = new MySqlConnection("server=localhost;user id=root; password=sa123; database=mer; CharSet=utf8"); MySqlDataReader sqlDataReader; MySqlCommand sqlCmd; myConnection.Open(); string sql = string.Format("SELECT * FROM health_care where Account_number ='{0}' and Password = '{1}'",id_textBox.Text,pass_textBox.Text); sqlCmd = new MySqlCommand(sql, myConnection); sqlDataReader = sqlCmd.ExecuteReader(); if (sqlDataReader.Read()) { string 變數 = MaxCodeSqlData["資料表名稱"].ToString(); } sqlDataReader.Close(); myConnection.Close();
沒有留言:
張貼留言