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_N AME, Administrator.ITEMS.SALESD ESCRIPTION FROM Administrator.ITEMS WHERE Administrator.ITEMS.PART_B ELONGS_TO_ ID = 2519")
myConnection.ConnectionStr ing = "Dsn=NetSuite.com;uid=jeff @mynet.net ;pwd=passw ord"
Cmd.Connection = myConnection
myConnection.Open()
Cmd.ExecuteReader()
GridView1.DataBind()
End Sub
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_N
myConnection.ConnectionStr
Cmd.Connection = myConnection
myConnection.Open()
Cmd.ExecuteReader()
GridView1.DataBind()
End Sub
i.e.
GridView1.DataSource = Cmd.ExecuteReader()
GridView1.DataBind()
GridView1.DataSource = Cmd.ExecuteReader()
GridView1.DataBind()
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.
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
THANK YOU!
This worked perfectly!
Thank YOU!
This worked perfectly!
Thank YOU!
Glad to help :-)
Open in new window
Are you missing something to bind GridView1 to the SqlDataReader returned??