我目前将DATAGRIDVIEW1绑定到SQL Server存储过程。它目前返回整个表。我在存储过程的select语句中添加了YEAR
参数。我的VB将年份文本框默认为
Me.GettestsTableAdapter.Fill(Me.CW_DataDataSet.gettests)
行在Form1_Load
中执行。我可以在此tableadapter填充中发送年份参数吗?谢谢
VB的表单加载如下:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
yr.Text = Str(Year(Today))
'TODO: This line of code loads data into the 'CW_DataDataSet.gettests' table. You can move, or remove it, as needed.
Me.GettestsTableAdapter.Fill(Me.CW_DataDataSet.gettests)
'TODO: This line of code loads data into the 'CW_DataDataSet.gettests' table. You can move, or remove it, as needed.
TextBox1.Text = Str(DataGridView1.RowCount)
TextBox1.Refresh()
End Sub
SQL Server存储过程执行:
SELECT
test_name, test_date, test_qn_result, test_ql_result,
test_domain, client_ID
FROM
testfile
WHERE
YEAR(test_date) = @YEAR