如题,将满足条件的数据取出到一个数据集,需要的时候调用
类似于var
   xsje:string;
begin
    adodataset.close;
    adodataset.commandtext:='select a.*,b.* form table a left join teble1 b on a.id=b.pid';
    adodataset.open;
    //那么在adodataset里我可以取任何字段的值,例如:
    xsje:=adodataset..fieldbyname('je').AsString;
end;但是在VB.net中不知道用哪个    Protected Sub GridView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
        GridView1.SelectedIndex = e.NewSelectedIndex
        Dim comm As Data.SqlClient.SqlCommand
        Dim da As Data.SqlClient.SqlDataAdapter
        Dim dt As Data.DataTable
        Dim da1 As Data.DataSet
        Dim xsdd As String '第一个gridview的行号变量
        xsdd = Me.GridView1.SelectedRow.Cells("3").Text
'VB.NET中的变量要取值,我现在就知道从gridveiw中取,但是如果没有显示在gridview中是字段呢,是不是也可以像delphi一样new一个数据集,然后调用里面各字段的值呢??
        Application("xsdh") = xsdd  '参数传递,变量xsdh在所有的aspx中都可能使用
        comm = New Data.SqlClient.SqlCommand("SELECT sp_xsdh,sp_mx,sp_sl,sp_dj,isnull(sp_je,0) as sp_je,sp_bz,hkrq,fpje,kprq,kpdw,fph FROM spmx WHERE sp_xsdh = '" & xsdd & "'", conn)
        da = New Data.SqlClient.SqlDataAdapter
        da1 = New Data.DataSet()
        comm.CommandType = Data.CommandType.Text
        da.SelectCommand = comm
        dt = New Data.DataTable
        da.Fill(dt)
        GridView2.DataSource = dt
        GridView2.DataBind()
    End Sub

解决方案 »

  1.   

    自己搞定,将数据取出来填充到表datatable中,再从表中取值出来, 不过不知道当数据量大时这样做的效率怎么样        Dim oconnection As New Data.SqlClient.SqlConnection("server=localhost;database=text;uid=sa;pwd=")
            Dim m_Comm As Data.SqlClient.SqlDataAdapter
            Dim m_DataTable As New Data.DataTable
            Dim a, b, c As String
            Dim sql1 As String
            sql1 = "select a,b,c from table where 1<>1"
            m_Comm = New Data.SqlClient.SqlDataAdapter(sql1, oconnection)
            m_Comm.Fill(m_DataTable)
            a = m_DataTable.Rows(0)("a").ToString() '第一行字段“a”的值
            b = m_DataTable.Rows(0)("b").ToString()
            c = m_DataTable.Rows(0)("c").ToString()分都散不出去,晕