I created some code to bind data to a datagrid control however when the user clicks on the button no data is displayed. I am using MySQL as my database system and have Imports System.Data.Odbc added in the beginning of my code. I have also added a control to the webform. I tried the code both without and with the grid on the form. Any help is appreciated. I apologize for being so full of questions but im new to ASP.NET and im trying to get these few issues straight so I can start full out using the features instead of VB 6.0.
Code:
VB Code:
Private Sub cmdView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdView.Click Dim myConn As String myConn = "Driver={MySQL ODBC 3.51 Driver};SERVER=appserver.domain.net;PORT=3306;DATABASE=database;UID=Username;PASSWORD=Password;OPTION=147458;" Dim mySQL As New OdbcConnection(myConn) mySQL.Open() Dim dg1 As New DataGrid() Dim selectQuery As String selectQuery = "SELECT type, make, serial, custID, sysID FROM stamissys WHERE type = '" & txtType.Text & "'" Dim datacommand As New OdbcCommand(selectQuery, mySQL) dg1.DataSource = datacommand.ExecuteReader dg1.DataBind() mySQL.Close() End Sub




Reply With Quote