hi,all my friends!
I am a new coder!
Recently,I found Entity Framework could easily manage database,but I didn't understand it.
I want to learn it,so I wrote a simple program to manage two tables in MySQL database.
I use VS2010.
Reference:
Tutorial: Using an Entity Framework Entity as a Windows Forms Data Source[
^]
MySQL tables:(Model1.edmx have these tables)
CREATE TABLE `lineinfo` (
`STT` BIGINT(20) NOT NULL AUTO_INCREMENT,
`Line` VARCHAR(50) NULL DEFAULT NULL,
`IP` VARCHAR(50) NULL DEFAULT NULL,
`Process` VARCHAR(50) NULL DEFAULT NULL,
`Version` VARCHAR(50) NULL DEFAULT NULL,
`user_ip` VARCHAR(50) NULL DEFAULT NULL,
`user_datetime` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`STT`)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM
CREATE TABLE `version` (
`STT` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`Process` VARCHAR(50) NULL DEFAULT NULL,
`Version` VARCHAR(50) NULL DEFAULT NULL,
`Path` VARCHAR(800) NULL DEFAULT NULL,
`user_ip` VARCHAR(50) NULL DEFAULT NULL,
`user_datetime` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`STT`)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM
My program code:
(I can change data in datagridview)
private void Form1_Load(object sender, EventArgs e)
{
tblversiontstcBindingSource.DataSource = db.version;
tbllineinfotstcBindingSource.DataSource = db.lineinfo;
}
private void button_update_Click(object sender, EventArgs e)
{
db.SaveChanges();
}
My questions:
1.db.SaveChanges();
This method can save two tables's changes,but i need separately save tables's changes,how to do?
2.datagridview show a part of table,user_ip and user_datetime are not in datagridview.
I want to change data in datagridview,then db.SaveChange(),upload IP and Time to user_ip and user_datetime at the same time.I don't know how to do?
3.How to use filter and order by in Entity Framework?
if (this.comboBox_process.Text == "ALL")
{
tblversiontstcBindingSource.DataSource = db.tblversion_tstc;
}
else if(this.comboBox_process.Text == "IMEI")
{
tblversiontstcBindingSource.DataSource =
}
4.what is Settings.settings file?
I create a MyConnectionString(server=localhost;User Id=robot;password=tstcrobot;Persist Security Info=True;port=1081;database=robot) in Settings.settings file.
I don't know what it is useful?
5.I don't know how to run my program in other PC,if i use Entity Framework ?
Please help!
Thank you very much!