はVB-ヒントからの例です:
http://www.vb-tips.com/dbPages.aspx?ID=5dbe894a-a7e6-434c-bd84-73494c71063f
Imports System.Data.SqlClient
Imports System.Text
Imports System.ComponentModel
Public Class Form1
Dim da As SqlDataAdapter
Dim conn As SqlConnection
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConn As String
Dim cmd As SqlCommand
Dim sbCmd As New StringBuilder
strConn = String.Format("Server = {0};", Environment.MachineName)
strConn &= "Database = NorthWind; Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
cmd = New SqlCommand("Select count(ProductName) From Products", conn)
Try
da = New SqlDataAdapter("Select * from Products", conn)
conn.Open()
With nuPage
.Maximum = Math.Ceiling(cmd.ExecuteScalar/10)
.Minimum = 1
.Increment = 1
.Value = 1
End With
conn.Close()
da.Fill(ds, 0, 10, "Products")
ds.Tables("Products").DefaultView.AllowNew = False
DataGridView1.DataSource = ds.Tables("Products")
For Each col As Object In DataGridView1.Columns
If TypeOf col Is DataGridViewCheckBoxColumn Then
DirectCast(col, DataGridViewCheckBoxColumn).Visible = False
ElseIf TypeOf col Is DataGridViewTextBoxColumn Then
Dim tbc As DataGridViewTextBoxColumn = CType(col, DataGridViewTextBoxColumn)
If tbc.Name = "ProductName" Then
tbc.Width = 275
tbc.HeaderText = "Product Name"
ElseIf tbc.Name = "UnitPrice" Then
tbc.Width = 75
tbc.HeaderText = "Price"
tbc.DefaultCellStyle.Format = "c"
tbc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
Else
tbc.Visible = False
End If
End If
Next
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try
End Sub
Private Sub nuPage_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nuPage.ValueChanged
Dim intStart As Integer = (nuPage.Value - 1) * 10
ds.Clear()
da.Fill(ds, intStart, 10, "Products")
End Sub
End Class
私は250のSQL文を管理していると言いましょう。この方法では、今度は、それぞれを(500個のstmts)のSQLの「カウント(*)風味」バージョンにする必要があります。 +1は私に "da"がmin、maxを持っていたことを示しています。 – BuddyJoe