|
 |
|
การลบและการแก้ไขค่าใน DataGridview ที่เชื่อมกับ Access เป็นฐานข้อมูล |
|
 |
|
|
 |
 |
|
ท่านใดมีแนวทางก็ขอรบกวนด้วยครับ ผมไปถามอ.แล้วว่า
command.CommandText = "INSERT INTO tb_item (รหัสสินค้า,ชื่อสินค้า,ชนิดพัสดุ,ประเภทพัสดุ,หมายเหตุ) VALUES (@รหัสสินค้า,@ชื่อสินค้า,@ชนิดพัสดุ,@ประเภทพัสดุ,@หมายเหตุ)";
//command.Parameters.AddWithValue("@วันที่", lb_Times.);
command.Parameters.AddWithValue("@รหัสสินค้า", tb_code.Text);
ไห้เปลี่ยนตรง INSERT INTO เป็น DELETE INTO () VALUES () แบบนี้ใช่หรือปล่าวครับ
แล้วถ้าเปลี่ยนแล้ว จะใช้คำสั่งใดในการลบหรอครับ ก็เหมือนกับเวลาเพิ่มเราใช้คำสั่ง Parameters.AddWithValue ใช่ใหมครับ แต่ ลบจะใช้อ่ะไรหรอครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-02-11 12:25:30 |
By :
l3ankrakke |
View :
2077 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ช่วยได้มากเลยทีเดียว
|
 |
 |
 |
 |
Date :
2010-02-12 17:11:10 |
By :
l3ankrakke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษนะครับ ขอถามอีกครั้งครับ คือ ..
ผมจะลบข้อมูลที่เชื่อมมาจาก Access หนะครับที่เป็นแถวของdataGridViewครับ
แบบว่าเวลาคริ๊กที่แถวใด แล้วกดลบก็จะลบแถวนั้นหนะครับผมงงมากเลยเพราะผมเขียนเป็นแบบนี้ครับ
command.CommandText = "DELETE FROM tb_item WHERE ''=@tb_Comment";
command.Parameters.AddWithValue("@รหัสสินค้า", tb_code.Text);
command.Parameters.AddWithValue("@ชื่อสินค้า", tb_name.Text);
command.Parameters.AddWithValue("@ชนิดพัสดุ", cb_type1.Text);
command.Parameters.AddWithValue("@ประเภทพัสดุ", cb_type2.Text);
command.Parameters.AddWithValue("@หมายเหตุ", tb_Comment.Text);
command.ExecuteNonQuery();
ถ้าผมไม่ใส่ค่าใน DELETE FROM tb_item WHERE 'ในนี้มันต้องค่าใดครับ'=ตรงนี้เช่นกันครับผมสงสัยมากเลยแล้วพยายามลองหาคำตอบดูต่างๆนาๆ กลับปรากฏว่า ต้องไม่ใส่ค่าในช่อง รหัสพัสดุ ครับถึงลบได้ แบบงงครับ (แล้วมันเกี่ยวอะไรกันนี่) เลยอยากถามว่า
1. DELETE FROM tb_item WHERE 'ในนี้มันต้องค่าใดครับ'=ตรงนี้เช่นกันครับ ; 2ช่องนี้ต้องใส่ค่าเป้นอะไรครับแล้วมันทำหน้าที่ใด
2. แล้วทำไมเวลาลบผมถึงต้องไม่ใส่ค่าในช่องรหัสพัสดุก่อนถึงลบได้ครับ
3. เวลากดคริ๊กที่ตารางเป็นแถวหนึ่งซึ่งเป็นค่า Row (แนวนอน) เวลากดปุ่มลบมันก็จะลบปทั้ง Row 1 เลยอ่ะครับ ซึ่งผมทำได้แค่ลบไปทั้งหมดเลย
** ผมอาการหนักป่าวครับหนิ แบบงงครบ **
รบกวนท่านช่วยอธิบายไห้ผมฟังทีนะครับ เพราะต้องส่งอาทิตย์หน้าแล้วครับ
กราบขอบพระคุณเป็นอย่างสูงคับ หมดหนทางจริงๆ

|
 |
 |
 |
 |
Date :
2010-02-12 18:02:45 |
By :
l3ankrakke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|