WORK 10 สร้างไฟล์ SQLite DB
Code : MainForm.cs
SetDbMenuItemClickk :
{
this.IsMdiContainer = true;
FormSetting frmSettingDb = new FormSetting();frmSettingDb.MdiParent = this;
frmSettingDb.Show();
}
FormSetting.cs
Button1Click :
String dbName = "NLib.ldb";
dbName = textBox1.Text;
if (File.Exists(dbName)) {
MessageBox.Show("1A มีฐานข้อมูลอยู่แล้ว");
} else {
try {
System.Data.SQLite.SQLiteConnection.CreateFile(dbName);
MessageBox.Show("1B ไม่พบฐานข้อมูล\n สร้างฐานข้อมูล "
String dbName = "NLib.ldb";
dbName = textBox1.Text;
if (File.Exists(dbName)) {
MessageBox.Show("1A มีฐานข้อมูลอยู่แล้ว");
} else {
try {
System.Data.SQLite.SQLiteConnection.CreateFile(dbName);
MessageBox.Show("1B ไม่พบฐานข้อมูล\n สร้างฐานข้อมูล "
+dbName+"สำเร็จ");
} catch (Exception ee){
MessageBox.Show("1C พบความผิดพลาด\n ติดต่อผู้ดูแลล"
} catch (Exception ee){
MessageBox.Show("1C พบความผิดพลาด\n ติดต่อผู้ดูแลล"
+ ee.ToString());
}
}
0 ความคิดเห็น