我想要把查询的结果通过datagrid输出!!!
请把答案发到我得邮箱sjinli2003@yahoo.com.cn
不胜感激!!!
例程如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Me.IsPostBack Then
myConn.Open()
Dim select_informant As String = "select informant_no,informant_name from informant where informant_khno=" & Trim(Session("oper_khno")) & ""
Dim da_informant As SqlDataAdapter = New SqlDataAdapter(select_informant, myConn)
Dim ds As New DataSet()
da_informant.Fill(ds, "informant")
ds.Tables("informant").Columns(0).ColumnName = "编 号"
ds.Tables("informant").Columns(1).ColumnName = "姓 名"
DataGrid1.DataSource = ds.Tables("informant").DefaultView
DataGrid1.DataBind()
ds.Dispose()
myConn.Close()
End If
End Sub