Link to home
Create AccountLog in
Avatar of Wildone63
Wildone63

asked on

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
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Between these two lines
        Cmd.ExecuteReader()

        GridView1.DataBind()

Open in new window

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

        GridView1.DataSource = Cmd.ExecuteReader()
        GridView1.DataBind()
Avatar of Wildone63
Wildone63

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
THANK YOU!
This worked perfectly!

Thank YOU!
Glad to help :-)