Connecting to ODBC Database Problem

I am using VB.Net VS-2008.

I am trying to connect to a database via ODBC.
I think I finally have figured out the connection string issues etc... but when I run the ASPX page that has a gridview on it I do not get any results.

Here is what I am trying.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myConnection As OdbcConnection = New OdbcConnection()
        Dim Cmd As New OdbcCommand("SELECT Administrator.ITEMS.FULL_NAME, Administrator.ITEMS.SALESDESCRIPTION FROM Administrator.ITEMS WHERE Administrator.ITEMS.PART_BELONGS_TO_ID = 2519")
        myConnection.ConnectionString = "Dsn=NetSuite.com;uid=jeff@mynet.net;pwd=password"
        Cmd.Connection = myConnection
        myConnection.Open()
        Cmd.ExecuteReader()

        GridView1.DataBind()


    End Sub
LVL 1
Wildone63Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cyberkiwiCommented:
Between these two lines
        Cmd.ExecuteReader()

        GridView1.DataBind()

Open in new window

Are you missing something to bind GridView1 to the SqlDataReader returned??
cyberkiwiCommented:
i.e.

        GridView1.DataSource = Cmd.ExecuteReader()
        GridView1.DataBind()
Wildone63Author Commented:
I added this

        myConnection.Open()

        GridView1.DataSource = Cmd.ExecuteReader()

        GridView1.DataBind()

but still do not get anything returned. When I run the query manually I do get a return of 3 records.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

CodeCruiserCommented:
Try changing the whole code in page load to this



Dim dbadp As New OdbcDataAdapter("SELECT Administrator.ITEMS.FULL_NAME, Administrator.ITEMS.SALESDESCRIPTION FROM Administrator.ITEMS WHERE Administrator.ITEMS.PART_BELONGS_TO_ID = 2519","Dsn=NetSuite.com;uid=jeff@mynet.net;pwd=password")
        Dim dTable As New DataTable
        dbadp.Fill(dTable)
        dbadp.Dispose
        GridView1.DataSource = dTable
        GridView1.DataBind()

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wildone63Author Commented:
THANK YOU!
This worked perfectly!

Thank YOU!
CodeCruiserCommented:
Glad to help :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.