我正在尝试按姓氏搜索数据库,并将结果集显示在页面上的表格中。不幸的是我不知道该怎么做。
这是存储过程
ALTER PROCEDURE dbo.uspSelectPatient
@lName varchar(25)
AS
SELECT lName, fName, patientId, birthday
FROM dbo.Patients
WHERE lName = @lName
RETURN
当用户单击按钮时,运行proc。我想我有一切都接受显示器设置。
Protected Sub btnSearch_Click(sender As Object, e As System.EventArgs) Handles btnSearch.Click
'Open DB
Dim objCon As New SqlConnection(mstrCN)
objCon.Open()
'Define Command
Dim objCmd As SqlCommand = New SqlCommand("uspSelectPatient", objCon)
objCmd.CommandType = Data.CommandType.StoredProcedure
'Define Data Adapter
Dim objDataAdapter As New SqlDataAdapter(objCmd)
'Define Dataset
Dim objDataSet As New Data.DataSet
'Fill DataSet
objDataAdapter.Fill(objDataSet, "Search")
'Not sure what goes here?
'Close Objects
objCmd.Dispose()
objDataAdapter.Dispose()
objCon.Close()
objCon.Dispose()
End Sub