QueriesTableAdapter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • peterg12345@gmail.com

    QueriesTableAdapter

    Newbie question:

    I have created a custom query using the Query Builder, and it shows up
    as a QueriesTableAda pter entry in the .xsd file. Now, how do I make
    the results of this query available to a grid object on my form? IOW,
    how do I make it a data source?


    TIA
  • Rich P

    #2
    Re: QueriesTableAda pter

    Using the wizards will restrict your objects considerably. You are
    better off doing this in code as follows (I am using Windows
    Authentication in this sample if you are using Sql Server):

    --------------------------------------------
    Imports System
    Imports System.Data.Sql Client

    Dim conn As SqlConnection, da As SqlDataAdapter
    Dim ds As Dataset

    Private Sub Form1_Load(...) Handles MyBase.Load
    conn1 = New SqlConnection
    conn1.Connectio nString = "Data Source=yourSvr; Initial
    Catalog=yourDB; Integrated Security=True"

    ds = New Dataset
    da = New SqlDataAdapter
    da.SelectComman d = New SqlCommand
    da.SelectComman d.Connection = conn
    da.SelectComman d = "Select * From yourTbl"
    da.Fill(ds, "tblSteve")

    datagridview1.D ataSource = ds.Tables("tblS teve")
    End Sub
    ----------------------------------------------

    Just create a new form and drop a datagridview control on it. Then copy
    and paste the code above into your new form. Replace yourTbl with the
    name of an actual table on your server DB. Now load the project and you
    will see the data in your form's datagridview control.

    Rich

    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • =?Utf-8?B?cGV0ZXJnMTIzNDU=?=

      #3
      Re: QueriesTableAda pter

      Thanks Rich - that's what I was looking for.

      "Rich P" wrote:
      Using the wizards will restrict your objects considerably. You are
      better off doing this in code as follows (I am using Windows
      Authentication in this sample if you are using Sql Server):
      >
      --------------------------------------------
      Imports System
      Imports System.Data.Sql Client
      >
      Dim conn As SqlConnection, da As SqlDataAdapter
      Dim ds As Dataset
      >
      Private Sub Form1_Load(...) Handles MyBase.Load
      conn1 = New SqlConnection
      conn1.Connectio nString = "Data Source=yourSvr; Initial
      Catalog=yourDB; Integrated Security=True"
      >
      ds = New Dataset
      da = New SqlDataAdapter
      da.SelectComman d = New SqlCommand
      da.SelectComman d.Connection = conn
      da.SelectComman d = "Select * From yourTbl"
      da.Fill(ds, "tblSteve")
      >
      datagridview1.D ataSource = ds.Tables("tblS teve")
      End Sub
      ----------------------------------------------
      >
      Just create a new form and drop a datagridview control on it. Then copy
      and paste the code above into your new form. Replace yourTbl with the
      name of an actual table on your server DB. Now load the project and you
      will see the data in your form's datagridview control.
      >
      Rich
      >
      *** Sent via Developersdex http://www.developersdex.com ***
      >

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: QueriesTableAda pter

        Pete-

        I don't mean to sound stupid, but could you clarify the result you want to
        get.
        Right now, I am looking at a solution for a non strongly typed dataset which
        does not have a
        QueriesTableAda pter object containing your SQL -- qryIssuesList() .

        What has this to do with a xsd file into?

        TIA,
        Cor


        "peterg1234 5" <peterg12345@di scussions.micro soft.comschreef in bericht
        news:088D7FB3-D01C-44BF-8D67-9B46056AFBD5@mi crosoft.com...
        Thanks Rich - that's what I was looking for.
        >
        "Rich P" wrote:
        >
        >Using the wizards will restrict your objects considerably. You are
        >better off doing this in code as follows (I am using Windows
        >Authenticati on in this sample if you are using Sql Server):
        >>
        >--------------------------------------------
        >Imports System
        >Imports System.Data.Sql Client
        >>
        >Dim conn As SqlConnection, da As SqlDataAdapter
        >Dim ds As Dataset
        >>
        >Private Sub Form1_Load(...) Handles MyBase.Load
        >conn1 = New SqlConnection
        >conn1.Connecti onString = "Data Source=yourSvr; Initial
        >Catalog=yourDB ;Integrated Security=True"
        >>
        >ds = New Dataset
        >da = New SqlDataAdapter
        >da.SelectComma nd = New SqlCommand
        >da.SelectComma nd.Connection = conn
        >da.SelectComma nd = "Select * From yourTbl"
        >da.Fill(ds, "tblSteve")
        >>
        >datagridview1. DataSource = ds.Tables("tblS teve")
        >End Sub
        >----------------------------------------------
        >>
        >Just create a new form and drop a datagridview control on it. Then copy
        >and paste the code above into your new form. Replace yourTbl with the
        >name of an actual table on your server DB. Now load the project and you
        >will see the data in your form's datagridview control.
        >>
        >Rich
        >>
        >*** Sent via Developersdex http://www.developersdex.com ***
        >>

        Comment

        Working...