Results 1 to 2 of 2

Thread: Datagrid On the Fly

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    india
    Posts
    95

    Datagrid On the Fly

    i have a sql query

    select A.topcol,B.fstcol from table1 A,table2 B.....

    im trying to contruct a datagrid with title column from one table and 1st column from another table record


    how to implement this datagrid on the fly
    or is any other way to contruct this with Table object?

    v.r.mahendran
    Attached Images Attached Images  

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    Mahivr, this is what I did. If you use your select statement like this... Select Vendor_ID as [Vendor ID]... Then the column header will be Vendor ID. Here is an example.
    VB Code:
    1. Dim cn As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
    2.                                  & "Persist Security Info=False;" _
    3.                                  & "Initial Catalog=fuel info;" _
    4.                                  & "UID=;PWD=;" _
    5.                                  & "Data Source=Server7")
    6.             cn.Open()
    7.  
    8.             Dim datAdapt As New OleDb.OleDbDataAdapter("Select Vendor_No as [Vendor No], " & _
    9.             "Vendor_Name as [Vendor Name], Vendor_Terminal as [Vendor Terminal], " & _
    10.             "Vendor_Trmnl_No As [Terminal No], Vendor_City As [City], Vendor_State As " & _
    11.             "[State], ID From Other_Vendors Order By Vendor_Name", cn)
    12.  
    13.             Dim datSet As New Data.DataSet
    14.  
    15.             datAdapt.Fill(datSet, "Other_Vendors")
    16.  
    17.             DataGrid1.DataSource = datSet
    18.             DataGrid1.DataKeyField = "ID"
    19.             DataGrid1.DataBind()
    David Wilhelm

Posting Permissions

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



Click Here to Expand Forum to Full Width