Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    66

    Unanswered: How to store/display more than one tables/recordset

    see the follow code:
    can return more than one recordset/table
    the datagrid can show more than one table at a time.
    1.the problem is how to store more than one table in a dataset at a time.
    2.see sql(2),sql(3), the new table 't1' is empty, after exec sql(3) will meet a "System.Data.OleDb.OleDbException",the sql(2) can pass without return recordset, but sql(3) return a null recordset(maybe). What should I do.
    thanks.

    Public Function m_execsql()
    Dim connStr As String
    connStr = "User ID=sa;Password=sa;Initial Catalog=Northwind;Provider=""SQLOLEDB.1"";Data Source=MINGLEI"
    conn = New System.Data.OleDb.OleDbConnection(connStr)
    conn.Open()
    Dim sql(3) As String
    sql(0) = "select * from products;"
    sql(1) = "select * from orders;"
    sql(2) = "create table t1;"
    sql(3) = "seletc * from t1;"
    Dim i As Integer
    For i = 0 To sql.GetUpperBound(0) - 1
    Try
    da = New OleDb.OleDbDataAdapter(sql(i), conn)
    Catch e As Exception
    MessageBox.Show(e.Message)
    End Try
    'Try
    ds = New DataSet("dsTable")
    dt = New DataTable
    da.Fill(ds)
    'grd.SetDataBinding(ds, i.ToString)
    grd.DataSource = dt
    'Catch eds As Exception
    ' MessageBox.Show(eds.Message)
    'End T
    Next
    conn.Close()
    conn = Nothing
    End Function

  2. #2
    Join Date
    Sep 2003
    Posts
    60

    Re: How to store/display more than one tables/recordset

    iqueen, you can use multiple data adapters to fill one dataset or if your sql statement returned more than one result set.

    Here's more from MS KB:
    http://msdn.microsoft.com/library/de...ataadapter.asp

    You may want post in .Net section too....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •