VB2010 ODBC SQL Query to DataGridView

Posted on 2014-08-05
Last Modified: 2014-08-05
Hello Experts,

I am coming over from VB6 to VB2010 and I am am having a hell of time getting the results of a basic query to display on a datagrid.

In VB6 I would only need 2 components: DataGridView and an ADODC object. I would link the DataGridView's DataSoucre to the ADODC object, put my ODBC info into the ADODC object, then write 2 lines of code:

adodc1.recordsource = "select * from table where condition = x"

and bam!

I am completely lost in I dont understand the Fill, BindingSource, TableAdapter, etc. and how they work with each other or why they are even needed.

Can someone point me in the right direction?
Question by:triphen
    1 Comment

    Accepted Solution

    I got it !!!!!!!!!

    Dim str As String = "DSN=NAME;uid=USER;pwd=PASSWORD;"
            Dim con As New OdbcConnection(str)
            Dim com As String = "Select prodnum, descript, pricea from dba.product where descript like '%" & TextBox1.Text & "%'"
            Dim Adpt As New OdbcDataAdapter(com, con)
            Dim ds As New DataSet()
            DataGridView1.DataSource = ds.Tables(0)

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now