PARUN
Would you like to react to this message? Create an account in a few clicks or log in to continue.

VB Code :: โค้ดแก้ไข

Go down

VB Code :: โค้ดแก้ไข Empty VB Code :: โค้ดแก้ไข

ตั้งหัวข้อ  Admin Tue Dec 23, 2008 1:23 am

tr = Conn.BeginTransaction()
Try
sb = New StringBuilder()
sb.Append("UPDATE Goods")
sb.Append(" SET Goods_Des=@Goods_Des,Goods_Rate=@Goods_Rate")
sb.Append(" WHERE (Goods_ID=@Goods_ID)")


Dim sqlEdit As String
sqlEdit = sb.ToString

With com
.CommandText = sqlEdit
.CommandType = CommandType.Text
.Connection = Conn
.Transaction = tr
.Parameters.Clear()
.Parameters.Add("@Goods_ID", SqlDbType.NVarChar).Value = txtGoodsID.Text.Trim()
.Parameters.Add("@Goods_Des", SqlDbType.NVarChar).Value = txtGoodsDes.Text.Trim()
.Parameters.Add("@Goods_Rate", SqlDbType.Float).Value = txtGoodsRate.Text.Trim()

Dim result As Integer
result = .ExecuteNonQuery()
If result = 0 Then
tr.Rollback()
MessageBox.Show("รหัสชนิดห้องพักที่คุณป้อน ไม่ถูกต้อง !!!", "แจ้งข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtGoodsID.SelectAll()
Else
tr.Commit()

ClearAllData()
showData()
FormatDgvGoods()

End If

End With
Catch ex As Exception
tr.Rollback()
MessageBox.Show("เกิดข้อผิดพลาด เนื่องจาก " & ex.Message, "แจ้งข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Try
End If
txtGoodsDes.Focus()

Admin
Admin
Admin

จำนวนข้อความ : 58
Registration date : 17/09/2008

http://parun.forumotion.net

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน

- Similar topics

 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ