|
![](/images/resource/spacer.gif) |
|
C# Windows form มีปัญหาเกี่ยวกับการอัพเดทฐานข้อมูล Microsoft Access |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
คือ ผมทำโปรแกรมหนึ่ง โดยใช้ Visual studio 2012 Ultimate ภาษา C# ใช้ฐานข้อมูล Ms Access
- ปัญหาก็คือ ผม select ข้อมูลจากฐานข้อมูล แสดงใน DatagridView แล้วเมื่อคลิกเลือกที่ DatagridView จะส่งค่าที่ต้องการแก้ไขมาใส่ใน Textbox แล้วส่งไอดีไปเก็บไว้ใน Variable 1 ตัว เพื่อใช้ในการอัพเดท แต่ เมื่อลองทดสอบรันโปรแกรมแล้ว DatagridView แสดงข้อมูลปกติ
คลิกเลือกรายการได้ปกติ แต่เวลาคลิกปุ่มอัพเดทแล้ว โปรแกรมจะค้าง!!! ไปเลยครับ ทิ้งไว้ครู่ไปเช็คในฐานข้อมูล มีการอัพเดทครับ แต่โปรแกรมค้าง มันเกิดจากอะไรครับ
โค้ดอัพเดท
Code (C#)
try
{
objconn = dbcon.Connection_db();
string updateQuery = "UPDATE CurrencyTb SET BuyRate = " + buy + ", SellRate = " + sell + " WHERE ID = " + id + " ";
OleDbCommand cmd = new OleDbCommand(updateQuery, objconn);
cmd.ExecuteNonQuery();
MessageBox.Show("Currency update", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Disconnection();
โค้ด Select
Code (C#)
try
{
objconn = dbcon.Connection_db();
strSQL = "SELECT ID, Code, CurrencyName, BuyRate, SellRate FROM CurrencyTb order by ID ASC ";
OleDbCommand cmd = new OleDbCommand(strSQL, objconn);
cmd.CommandType = CommandType.Text;
da = new OleDbDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
รบกวนผู้รู้ด้วยครับ
ขอย้ำนะครับ โปรแกรมค้างไปเลย ต้องไปคลิกที่ปุ่ม Stop Debug ใน Visual studio ครับ จึงจะหยุด
ขอบคุณล่วงหน้าครับ
Tag : .NET, Ms Access, Win (Windows App), VS 2012 (.NET 4.x)
![](/images/adv.jpg?v=1001)
|
ประวัติการแก้ไข 2015-07-25 00:04:15
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-25 00:02:29 |
By :
ideasza |
View :
1123 |
Reply :
3 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
มี Exception หรือ Log หรืออะไรอื่น ๆ แจ้งไหม๊ครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-25 19:34:55 |
By :
mr.win |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ไม่มีครับ คือ มันอัพเดทได้ครับ แต่มันค้างครับ....
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-25 20:50:22 |
By :
ideasza |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ได้ละครับ เกิดจาก
Code (C#)
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
System.Windows.Forms.DataGridViewCellStyle boldStyle = new System.Windows.Forms.DataGridViewCellStyle();
boldStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.5F, System.Drawing.FontStyle.Bold);
dataGridView1.Rows[e.RowIndex].DefaultCellStyle = boldStyle;
}
คือ พยายามจะเซ็ตให้ตัวหนังสือใน Datagridview เป็นตัวหน้า แต่พอลอง comment เท่านั้นแหละ ใช้ได้เลยครับ
ขอบคุณครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-26 22:23:59 |
By :
ideasza |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 01
|