動機:想用 Entity FrameWork 在正式機與測試機中,切換。
發生原因:因為正式機的 Entity edmx 沒有引用測試機的 table,導致正式機與測試機的模型不同,而 Entity 的 Dabe Frist 又是透過 模型來控制資料庫的,就會發生 Connect String 雖然正確,但 model 不對。
處理方式1:
將正式的 edmx 引入 測試站需要用到的 table
處理方式2:發生原因:因為正式機的 Entity edmx 沒有引用測試機的 table,導致正式機與測試機的模型不同,而 Entity 的 Dabe Frist 又是透過 模型來控制資料庫的,就會發生 Connect String 雖然正確,但 model 不對。
處理方式1:
將正式的 edmx 引入 測試站需要用到的 table
改用 SqlConnection 直接處理,DataSet,不透過 Entity 的 Model
var mySqlConnection = new SqlConnection("server=192.168.O.O;UID=XX;PWD=OO;DATABASE=CECDB");
var mySqlCommand = new SqlCommand("SELECT * FROM SMS_Bill WHERE Acpd_ID = 'sylin'", mySqlConnection);
mySqlConnection.Open();
var myDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
if (myDataReader.Read())
{
string temp = myDataReader["Account"].ToString();
myDataReader.Close();
mySqlCommand.Dispose();
rep.Message = temp;
rep.Success = true;
}
留言
張貼留言