Help with TableAdapter in VB Express

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy

    #1

    Help with TableAdapter in VB Express

    Hi,
    I'm trying to fill a combobox with values from a sql table. Data
    seems to be connected fine. Apparently in VB Express sqlDataAdapter
    doesn't work, or at least I can't make it work. Searching the help
    information, it directed me to Table Adapters instead.

    Can anybody help me with correcting this code. It doesn't like the
    sql statement at the end of table adapters declaration line. How do I
    get a sql statement to populate table values so that I can direct them
    to the combobox?

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)

    Dim PubsDS As New PUBSDataSet()
    Dim PubsTA As New
    PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
    publishers")

    PubsTA.Fill(Pub sDS.publishers)

    cboPubID.DataSo urce = PubsDS
    cboPubID.ValueM ember = "pub_id"
    cboPubID.Displa yMember = "pub_name"

    Thanks,
    Randy

  • aaron.kempf@gmail.com

    #2
    Re: Help with TableAdapter in VB Express

    table adapters are unnecessary

    ADO.net is hogwash

    stick with ADO classic, write data in HTML and don't follow the trendy
    'programming language of the month' paradigm




    On Apr 5, 8:35 am, "Randy" <spam.eastl...@ gmail.comwrote:
    Hi,
    I'm trying to fill a combobox with values from a sql table. Data
    seems to be connected fine. Apparently in VB Express sqlDataAdapter
    doesn't work, or at least I can't make it work. Searching the help
    information, it directed me to Table Adapters instead.
    >
    Can anybody help me with correcting this code. It doesn't like the
    sql statement at the end of table adapters declaration line. How do I
    get a sql statement to populate table values so that I can direct them
    to the combobox?
    >
    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)
    >
    Dim PubsDS As New PUBSDataSet()
    Dim PubsTA As New
    PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
    publishers")
    >
    PubsTA.Fill(Pub sDS.publishers)
    >
    cboPubID.DataSo urce = PubsDS
    cboPubID.ValueM ember = "pub_id"
    cboPubID.Displa yMember = "pub_name"
    >
    Thanks,
    Randy

    Comment

    • RobinS

      #3
      Re: Help with TableAdapter in VB Express

      Ignore AaronKempf; he's a troll.

      Robin S.
      -----------------------------
      "Randy" <spam.eastland@ gmail.comwrote in message
      news:1175787303 .549474.126360@ w1g2000hsg.goog legroups.com...
      Hi,
      I'm trying to fill a combobox with values from a sql table. Data
      seems to be connected fine. Apparently in VB Express sqlDataAdapter
      doesn't work, or at least I can't make it work. Searching the help
      information, it directed me to Table Adapters instead.
      >
      Can anybody help me with correcting this code. It doesn't like the
      sql statement at the end of table adapters declaration line. How do I
      get a sql statement to populate table values so that I can direct them
      to the combobox?
      >
      Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
      System.EventArg s) Handles MyBase.Load
      Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)
      >
      Dim PubsDS As New PUBSDataSet()
      Dim PubsTA As New
      PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
      publishers")
      >
      PubsTA.Fill(Pub sDS.publishers)
      >
      cboPubID.DataSo urce = PubsDS
      cboPubID.ValueM ember = "pub_id"
      cboPubID.Displa yMember = "pub_name"
      >
      Thanks,
      Randy
      >

      Comment

      • aaron.kempf@gmail.com

        #4
        Re: Help with TableAdapter in VB Express

        I am not a troll

        I just speak for truth

        Jihad against Microsoft; not all change is good
        not all change is trendy

        I won't change languages 'just because it's trendy thing to do'




        On Apr 5, 11:00 pm, "RobinS" <Rob...@NoSpam. yah.nonewrote:
        Ignore AaronKempf; he's a troll.
        >
        Robin S.
        -----------------------------"Randy" <spam.eastl...@ gmail.comwrote in message
        >
        news:1175787303 .549474.126360@ w1g2000hsg.goog legroups.com...
        >
        >
        >
        Hi,
        I'm trying to fill a combobox with values from a sql table. Data
        seems to be connected fine. Apparently in VB Express sqlDataAdapter
        doesn't work, or at least I can't make it work. Searching the help
        information, it directed me to Table Adapters instead.
        >
        Can anybody help me with correcting this code. It doesn't like the
        sql statement at the end of table adapters declaration line. How do I
        get a sql statement to populate table values so that I can direct them
        to the combobox?
        >
        Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
        System.EventArg s) Handles MyBase.Load
        Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)
        >
        Dim PubsDS As New PUBSDataSet()
        Dim PubsTA As New
        PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
        publishers")
        >
        PubsTA.Fill(Pub sDS.publishers)
        >
        cboPubID.DataSo urce = PubsDS
        cboPubID.ValueM ember = "pub_id"
        cboPubID.Displa yMember = "pub_name"
        >
        Thanks,
        Randy- Hide quoted text -
        >
        - Show quoted text -

        Comment

        • Randy

          #5
          Re: Help with TableAdapter in VB Express

          Grrrrrrrrrrr... ..

          Comment

          • RobinS

            #6
            Re: Help with TableAdapter in VB Express


            Table adapters are used with strongly typed datasets. You design these
            through the Data Designer. That doesn't seem like what you are doing. It
            sounds like you just want to read the database, get a table of data, and
            bind it to your combobox. Is that right?

            If so, try something like this:

            Dim dt as DataTable

            Using cn as New SqlConnection(m yConnectionStri ng)

            cn.Open()

            'Define the SQL Command object
            Dim cmd As SqlCommand = New SqlCommand()
            cmd.Connection = cn
            cmd.ComandType = CommandType.Tex t
            cmd.CommandText = ""SELECT * FROM publishers"

            Dim da As SqlDataAdapter = new SqlDataAdapter( cmd)
            dt = New DataTable()
            da.Fill(dt)

            End Using 'This closes the connection

            cboPubID.DataSo urce = dt
            cboPubID.ValueM ember = "pub_id"
            cboPubID.Displa yMember = "pub_name"

            Robin S.
            ----------------------
            "Randy" <spam.eastland@ gmail.comwrote in message
            news:1175787303 .549474.126360@ w1g2000hsg.goog legroups.com...
            Hi,
            I'm trying to fill a combobox with values from a sql table. Data
            seems to be connected fine. Apparently in VB Express sqlDataAdapter
            doesn't work, or at least I can't make it work. Searching the help
            information, it directed me to Table Adapters instead.
            >
            Can anybody help me with correcting this code. It doesn't like the
            sql statement at the end of table adapters declaration line. How do I
            get a sql statement to populate table values so that I can direct them
            to the combobox?
            >
            Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
            System.EventArg s) Handles MyBase.Load
            Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)
            >
            Dim PubsDS As New PUBSDataSet()
            Dim PubsTA As New
            PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
            publishers")
            >
            PubsTA.Fill(Pub sDS.publishers)
            >
            cboPubID.DataSo urce = PubsDS
            cboPubID.ValueM ember = "pub_id"
            cboPubID.Displa yMember = "pub_name"
            >
            Thanks,
            Randy
            >

            Comment

            • aaron.kempf@gmail.com

              #7
              Re: Help with TableAdapter in VB Express

              wow... that is funny

              do you know how many lines of code it takes me to build a databound
              combo box?

              UH ZERO?



              On Apr 7, 12:33 am, "RobinS" <Rob...@NoSpam. yah.nonewrote:
              Table adapters are used with strongly typed datasets. You design these
              through the Data Designer. That doesn't seem like what you are doing. It
              sounds like you just want to read the database, get a table of data, and
              bind it to your combobox. Is that right?
              >
              If so, try something like this:
              >
              Dim dt as DataTable
              >
              Using cn as New SqlConnection(m yConnectionStri ng)
              >
              cn.Open()
              >
              'Define the SQL Command object
              Dim cmd As SqlCommand = New SqlCommand()
              cmd.Connection = cn
              cmd.ComandType = CommandType.Tex t
              cmd.CommandText = ""SELECT * FROM publishers"
              >
              Dim da As SqlDataAdapter = new SqlDataAdapter( cmd)
              dt = New DataTable()
              da.Fill(dt)
              >
              End Using 'This closes the connection
              >
              cboPubID.DataSo urce = dt
              cboPubID.ValueM ember = "pub_id"
              cboPubID.Displa yMember = "pub_name"
              >
              Robin S.
              ----------------------"Randy" <spam.eastl...@ gmail.comwrote in message
              >
              news:1175787303 .549474.126360@ w1g2000hsg.goog legroups.com...
              >
              Hi,
              I'm trying to fill a combobox with values from a sql table. Data
              seems to be connected fine. Apparently in VB Express sqlDataAdapter
              doesn't work, or at least I can't make it work. Searching the help
              information, it directed me to Table Adapters instead.
              >
              Can anybody help me with correcting this code. It doesn't like the
              sql statement at the end of table adapters declaration line. How do I
              get a sql statement to populate table values so that I can direct them
              to the combobox?
              >
              Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
              System.EventArg s) Handles MyBase.Load
              Me.PublishersTa bleAdapter.Fill (Me.PUBSDataSet .publishers)
              >
              Dim PubsDS As New PUBSDataSet()
              Dim PubsTA As New
              PUBSDataSetTabl eAdapters.publi shersTableAdapt er()= ("SELECT * FROM
              publishers")
              >
              PubsTA.Fill(Pub sDS.publishers)
              >
              cboPubID.DataSo urce = PubsDS
              cboPubID.ValueM ember = "pub_id"
              cboPubID.Displa yMember = "pub_name"
              >
              Thanks,
              Randy

              Comment

              Working...