ด฿งข้อมูลออกมาแล้ว แต่หลายบรรทัดมาก ต้องการออกแค่10แถว เหลือจากนั้นให้เป็น next back
Code (VB.NET)
Private Sub showCredit()
sb = New StringBuilder()
sb.Remove(0, sb.Length)
sb.Append(" SELECT ROW_NUMBER()")
sb.Append(" OVER (ORDER BY Auto ASC) AS RowNo,")
sb.Append(" Edit,CheckID,PO,Cre_Cus_ID,Cre_Pay_Money,Cre_Pay_Date,Cre_Remake") ',Cre_StatusID,EmployeeID,
sb.Append(" FROM Creditor ")
sb.Append(" Where Cre_StatusID ='False'")
Dim sqlIni As String
sqlIni = sb.ToString()
com = New SqlCommand()
With com
.CommandText = sqlIni
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
End With
If dr.HasRows Then
Dim dtCre As DataTable
dtCre = New DataTable()
dtCre.Load(dr)
DgvCre.DataSource = dtCre
FormatDgvCre()
Else
DgvCre.DataSource = Nothing
End If
dr.Close()
End Sub
Private Sub FormatDgvCre()
With DgvCre
If .RowCount > 0 Then
.Columns(0).HeaderText = "ลำดับ"
.Columns(1).HeaderText = "สถานะ"
.Columns(2).HeaderText = "เลขที่เช็ค"
.Columns(3).HeaderText = "PO"
.Columns(4).HeaderText = "เจ้าหนี้"
.Columns(5).HeaderText = "จ่ายเงิน"
.Columns(6).HeaderText = "กำหนดจ่าย"
'.Columns(7).HeaderText = "พนักงาน"
.Columns(7).HeaderText = "หมายเหตุ"
.Columns(0).Width = 32
.Columns(1).Width = 32
.Columns(2).Width = 80
.Columns(3).Width = 80
.Columns(4).Width = 80
.Columns(5).Width = 80
.Columns(6).Width = 80
'.Columns(7).Width = 80
.Columns(7).Width = 120
End If
End With
End Sub