 |
|
ขอวิธีบันทึกข้อมูลจาก datagridview ลง sql หน่อยครับ |
|
 |
|
|
 |
 |
|
ตามนั้นครับ ใช้การ Loop ข้อมูลใน DataGridView ได้เลยครับ
Code (VB.NET)
For Each row As DataGridViewRow In Me.myDataGridView.Rows
// row.Cells("ColName").Value
Next
DataGridView (Win Form) สร้าง Custom แบบ Column/Header และการ Summary ผลรวม (VB.Net,C#)
|
 |
 |
 |
 |
Date :
2015-09-27 09:53:22 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองหาอ่านเพิ่มเติมบทความของ .NET กับ MySQL ครับ คุณเขียนผิดหลายจุดเลย
|
 |
 |
 |
 |
Date :
2015-09-28 22:12:55 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con As OleDbConnection = New OleDbConnection
Dim constring As String = "Data Source=ERPSERVER;Password=tum;User ID=sa;Initial Catalog=nyrubber1"
Dim Com As OleDbCommand
Dim pntruckno As String
Dim pnitemname As String
Dim pnunitcode As String
Dim str1 As String
Com = New OleDbCommand
Com.Connection = Con
For x As Integer = 0 To PNrubberDataGridView.Rows.Count - 1
pntruckno = PNrubberDataGridView.Rows(x).Cells(0).Value
pnitemname = PNrubberDataGridView.Rows(x).Cells(1).Value
pnunitcode = PNrubberDataGridView.Rows(x).Cells(2).Value
STR1 = "INSERT INTO pnissue() VALUES (@pntruckno, @pnitemname, @pnunitcode)"
Dim Comm As New OleDbCommand(STR1, Con)
Comm.Parameters.AddWithValue("@pnissue", pntruckno)
Comm.Parameters.AddWithValue("@Sales_Date", pnitemname)
Comm.Parameters.AddWithValue("@Copies", pnunitcode)
Comm.Dispose()
Next
MessageBox.Show("บันทึกข้อมูลแล้ว")
End Sub
บันทึกได้แล้วครับแต่ผมอยากให้มันโชว์ที่ละ 10 บรรทัด
|
 |
 |
 |
 |
Date :
2015-09-29 11:28:51 |
By :
dRufFy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|