Private Sub Cmdok_Click()
Dim sqlFarmer3 As String
Dim rsFarmer3 As New ADODB.Recordset
Dim sqlUpdate_RETURN3 As String
Dim comCANE_RETURN3 As New ADODB.Command
Dim sqlUpdateRent As String
Dim comRent As New ADODB.Command
Dim FFF As String
Dim R As Double
Dim RETURN1 As Double
Dim b As Integer
Dim i3 As String
Dim Fdate As String
Dim Tdate As String
Fdate = Format(txtFDate.Text, "dd/mm/yyyy")
Tdate = Format(txtTDate.Text, "dd/mm/yyyy")
Conn2.BeginTrans
sqlFarmer3 = "SELECT * From CPC_TRUC "
' sqlFarmer3 = sqlFarmer3 & " WHERE REPORTDATE BETWEEN '" & Format((Fdate), "mm/dd/yyyy") & "'"
' sqlFarmer3 = sqlFarmer3 & " AND '" & Format((Tdate), "mm/dd/yyyy") & "'"
' sqlFarmer3 = sqlFarmer3 & " AND PRINT_W='Y'"
' sqlFarmer3 = sqlFarmer3 & " Where PRINT_W='Y'"
'sqlFarmer3 = sqlFarmer3 & " AND (PERIOD_NO='" & txtPer.Text & "')"
'sqlFarmer3 = sqlFarmer3 & " AND LOAN>0"
sqlFarmer3 = sqlFarmer3 & " ORDER BY TRUCK_Q"
With rsFarmer3
If .State = adStateOpen Then .Close
.ActiveConnection = Conn2
.CursorType = adOpenForwardOnly
.CursorLocation = adUseClient
.Open sqlFarmer3
If .RecordCount = 0 Then
'Exit
Else
b = 0
i3 = 0
.MoveFirst
pgbProcess.Min = 0
pgbProcess.Max = .RecordCount
pgbProcess.Value = 0
R = 0
Do While Not .EOF
' MsgTxt.Caption = "¡ÓÅѧ¹Ó˹Õéà¢éÒÃкº FMS"
FFF = .Fields("TRUCK_Q")
i3 = i3 + 1
' MsgTxt.Caption = "¡ÓÅѧ»ÃÐÁÇżÅÃÇÁ¢éÍÁÙÅ"
sqlUpdateRent = "INSERT INTO CPC_TRUC (TRUCK_Q,Landno,FMCODE,FMCODE_B1, TRUCK_NO, Carduid,OWNCODE,regtruck,KEEP_NO,OWNCODE_KEEP,"
sqlUpdateRent = sqlUpdateRent & "CUT_NO,OWNCODE_CUT,PRINT_Q,REF_DOC1,"
sqlUpdateRent = sqlUpdateRent & "Q_ID,DATE_IN,REPORTDATE,TRUCK_Chk,Qtype,GROUPCODE)"
With comRent
.ActiveConnection = Conn1
.CommandType = adCmdText
.CommandText = sqlUpdateRent
.Execute
End With
pgbProcess.Value = pgbProcess.Value + 1
lblPercent.Caption = Int(pgbProcess.Value * 100 / pgbProcess.Max) & "%"
lblPercent.Refresh
.MoveNext
b = b + 1
R = R + 1
Label1.Caption = "จำนวน " & R & " รายการ"
Loop
End If
End With
Conn2.CommitTrans
Unload Me
End Sub
อันนี้เป็น VB.6 แต่อยากได้โค๊ดแบบนี้ใน VB.net ต้องเขียนประมาณไหนได้ครับแนะนำให้ด้วยน่ะครับ เพิ่งมาศึกษา VB.Net