 |
|
[VB.Net Window App] เวลา Edit ข้อมูล ข้อมูลเข้าไปใน DataGridView แต่ข้อมูลไม่ยอมบันทึกลง MS Access |
|
 |
|
|
 |
 |
|
คือตอน edit ข้อมูล ข้อมูลเข้าไปในdatagridview แต่ข้อมูลไม่ยอมบันทึกลงaccess อ่ะครับ
รูปก่อน edit

รูปหลัง edit

code
Public Sub updatePlannedItEquip(ByVal PlannedListID As Integer, ByVal ItemNo As String, ByVal ItemType As String, ByVal DateTimePicker1 As String, ByVal Contractor As String, ByVal Orderedtime As String, ByVal Qty As Integer, ByVal Unit As String, ByVal Remark As String)
Connect()
Dim olecom As OleDbCommand = Nothing
sqlcom = "UPDATE IT_PlannedList SET ItemNo = '" & ItemNo & "',ItemType = '" & ItemType & "',Qty = '" & Qty & "',Unit = '" & Unit & "',Remark = '" & Remark & "',OrderedTimes = '" & Orderedtime & "',ContractorID = '" & Contractor & "',DateCreated = '" & DateTimePicker1 & "'WHERE PlannedListID=" & PlannedListID & " "
olecom = New OleDbCommand(sqlcom, conn)
olecom.ExecuteNonQuery()
End Sub
Private Sub BNedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BNedit.Click
Connect()
If txtPlannedListID.Text = "" Or txtItemNo.Text = "" Or cmbItemType.Text = "" Or cmbContractor.Text = "" Or txtOrderedtime.Text = "" Or txtQty.Text = "" Or cmbData.Text = "" Or cmbUnit.Text = "" Or txtRemark.Text = "" Then
MessageBox.Show("กรุณาใส่ข้อมูล")
Else
Dim dt2 As DataTable = Nothing
Dim ds2 As New DataSet
Dim sqlCon As String = "SELECT * FROM Contractor where Contractor_Name LIKE '" & cmbContractor.Text & "'"
'MessageBox.Show(sqlSubSec)
Dim da2 As OleDbDataAdapter
da2 = New OleDbDataAdapter(sqlCon, conn)
da2.Fill(ds2, "Contractor")
dt2 = ds2.Tables("Contractor")
'TxtTemp
TxtTemp.DataBindings.Add(New Binding("text", dt2, "Contractor_ID"))
Dim NumDateM As String
Dim NumDate As String
NumDateM = condata.CheckData(cmbData.Text)
' MessageBox.Show(NumDateM)
Dim str = cmbData.Text
Dim strArr() As String
strArr = str.Split(CChar(" "))
NumDate = strArr(0) & "/" & NumDateM & "/" & strArr(2)
' MessageBox.Show(NumDate)
Dim Result As MsgBoxResult
Result = CType(MessageBox.Show("คุณต้องการบันทึกข้อมูลใช่หรือไม่", "คำเตือน", MessageBoxButtons.YesNo), MsgBoxResult)
If Result = MsgBoxResult.Yes Then
' MessageBox.Show(txtCVNo.Text)
Dim cmd As OleDbCommand = Nothing
Dim sqlSave As String = ""
condata.updatePlannedItEquip(PlannedListID:=txtPlannedListID.Text, ItemNo:=txtItemNo.Text, ItemType:=cmbItemType.Text, DateTimePicker1:=NumDate, Contractor:=TxtTemp.Text, Orderedtime:=txtOrderedtime.Text, Qty:=txtQty.Text, Unit:=cmbUnit.Text, Remark:=txtRemark.Text)
MessageBox.Show("ข้อมูลถูกบันทึกเรียบร้อย")
'MessageBox.Show(TextBox1.Text)
ElseIf Result = MsgBoxResult.No Then
MessageBox.Show("การบันทึก ถูกยกเลิก")
End If
' clearAllData()
End If
' DataGridView1.Refresh()
End Sub
Public Sub Connect()
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PMCBL_ITINV_V0.8.accdb"
.Open()
End With
End Sub
Tag : .NET, Ms Access, Win (Windows App), VB.NET, VS 2010 (.NET 4.x), Windows
|
|
 |
 |
 |
 |
Date :
2013-08-01 13:20:30 |
By :
ปวีณวัช |
View :
1643 |
Reply :
14 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มี Error หรือเปล่าครับ 
|
 |
 |
 |
 |
Date :
2013-08-01 13:34:01 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1. ดูข้อมูลในฐานข้อมูลว่าลงหรือยังครับ และ Error อะไรไหม ลองนำคิวรี่ไป Insert ดูในฐานข้อมูลก่อนก็ดีครับ
|
 |
 |
 |
 |
Date :
2013-08-01 13:39:53 |
By :
01000010 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มี error ครับ ดูในaccess แล้ว ครับ ข้อมูลไม่ ที่ edit เข้าไปไม่มีอ่ะครับ
|
 |
 |
 |
 |
Date :
2013-08-01 13:44:11 |
By :
ปวีณวัช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอา dim valNumberRows As Integer = olecom.ExecuteNonQuery() ใส่
Public Sub updatePlannedItEquip(ByVal PlannedListIDA As String, ByVal ItemNo As String, ByVal ItemType As String, ByVal DateTimePicker1 As String, ByVal Contractor As String, ByVal Orderedtime As String, ByVal Qty As Integer, ByVal Unit As String, ByVal Remark As String)
Connect()
Dim olecom As OleDbCommand = Nothing
'MessageBox.Show(CStr(_time))
' MessageBox.Show(PlannedListID)
sqlcom = "UPDATE IT_PlannedList SET ItemNo = '" & ItemNo & "',ItemType = '" & ItemType & "',Qty = '" & Qty & "',Unit = '" & Unit & "',Remark = '" & Remark & "',OrderedTimes = '" & Orderedtime & "',ContractorID = '" & Contractor & "',DateCreated = '" & DateTimePicker1 & "'WHERE PlannedListID=" & PlannedListIDA & " "
' sqlcom = "UPDATE IT_PlannedList SET Qty = '" & Qty & "',Unit = '" & Unit & "',Remark = '" & Remark & "' WHERE IT_PlannedList.PlannedListID=" & PlannedListIDA & " "
' MessageBox.Show(sqlcom)
olecom = New OleDbCommand(sqlcom, conn)
' olecom.ExecuteNonQuery()
Dim valNumberRows As Integer = olecom.ExecuteNonQuery()
MessageBox.Show(CStr(valNumberRows))
End Sub

|
 |
 |
 |
 |
Date :
2013-08-01 15:21:30 |
By :
ปวีณวัช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือ ตัวข้อมูลที่ อัพเดท อ่ะครับมานก็ลงในdatagridview อ่ะครับ แต่มานไม่ยอมลงในaccess ด้วยอ่ะครับ
|
 |
 |
 |
 |
Date :
2013-08-01 15:47:32 |
By :
ปวีณวัช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
edit ข้อมูลอ่ะครับ
คือ ตัวข้อมูลที่ edit อ่ะครับ มานก็ลงในdatagridview อ่ะครับตามที่วงกลมสีแดงรูปด้านบน แต่ข้อมูลมานไม่ยอมลงในaccess ด้วยอ่ะครับ
|
 |
 |
 |
 |
Date :
2013-08-01 16:00:17 |
By :
ปวีณวัช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|