 |
|
VB 2010 ช่วยแก้โค๊ด Edit : access 2007 ช่วยทีนะครับ |
|
 |
|
|
 |
 |
|
ผมใช้ database access 2007 ผมจะ Edit ข้อมูล ลองเขียนดูแล้ว มัน error ช่วยแก้หน่อยนะคับ
Code (VB.NET)
Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
If txtID.Text = "" Then
MessageBox.Show("กรุณาป้อนรหัสลูกค้าก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtID.Focus()
Exit Sub
End If
If txtName.Text = "" Then
MessageBox.Show("กรุณาป้อนชื่อลูกค้าก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtName.Focus()
Exit Sub
End If
If MessageBox.Show("คุณต้องการแก้ไขชื่อลูกค้า ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Dim dbsalon As DbProviderFactory = DbProviderFactories.GetFactory(strProvider)
Dim Conn As DbConnection = dbsalon.CreateConnection()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlProducts = "UPDATE goods SET (g_names = " & txtName.Text & ") WHERE (g_id = " & txtID.Text & ")"
Dim Com As DbCommand = Conn.CreateCommand()
If txtID.Text = "" Then
MessageBox.Show("กรุณาป้อนรหัสก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtID.Focus()
Exit Sub
End If
If txtName.Text = "" Then
MessageBox.Show("กรุณาป้อนชื่อก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtName.Focus()
Exit Sub
End If
Com.CommandText = sqlProducts
Dim ds As New DataSet()
Dim da As DbDataAdapter = dbsalon.CreateDataAdapter()
da.SelectCommand = Com
da.Fill(ds, "goods") 'มันบอกว่าผิดพลาดตรงนี้ครับ
dgv2.DataSource = ds.Tables("goods")
ShowData()
End If
txtID.Focus()
End Sub
Tag : .NET, Ms Access, VBScript, Win (Windows App), VS 2010 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2011-01-21 20:11:21 |
By :
korpor |
View :
2247 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error Message ว่าอะไรครับ 
|
 |
 |
 |
 |
Date :
2011-01-21 22:22:36 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

ช่วยทีนะครับ
|
 |
 |
 |
 |
Date :
2011-01-22 00:22:19 |
By :
korpor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
da.Fill(ds & "good")
|
 |
 |
 |
 |
Date :
2011-10-18 13:53:56 |
By :
fhaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง ตรวจ สอบ command ของตัว แปล com ว่า ใช้คำสั่งถูกหรือไม่ คับ ผมก็เดาๆไปงั้นนะ อิอิ
|
 |
 |
 |
 |
Date :
2012-03-19 00:20:49 |
By :
RENFIX |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|