Basically im trying to fill a Datagrid with the data from a mysql query
Basically i need to get the Data from the mysql Data adapter into the data grid veiw. The datagrid Veiw is called dgridmain. basically the code below returns
Error: Fill: Select.command has not been initialised.
Any help Please
Code:Dim searchtype As String Dim searchitem As String Dim precordcountint32 As String searchtype = "description" If RadioButton1.Checked = True Then searchtype = "barcode" ElseIf RadioButton2.Checked = True Then searchtype = "sku" ElseIf RadioButton3.Checked = True Then searchtype = "description" End If searchitem = TextBox1.Text Dim searchquerycmd As New MySql.Data.MySqlClient.MySqlCommand("SELECT * from products where " & searchtype & " = " & searchitem & "") Try Dim myConnectionString As String myConnectionString = "Database=ames;Data Source=" & globalserver & ";User Id=amesuser;Password=amespassword;" Dim myConnection As New MySql.Data.MySqlClient.MySqlConnection(myConnectionString) myConnection.Open() Using mMySqlDataAdapter As New MySql.Data.MySqlClient.MySqlDataAdapter(searchquerycmd) Using mDataSet As New DataSet mDataSet.Clear() mMySqlDataAdapter.Fill(mDataSet, "data") mDataView = New DataView mDataView.Table = mDataSet.Tables("data") precordcountint32 = mDataView.Count End Using End Using myConnection.Close() Catch searcherror As MySql.Data.MySqlClient.MySqlException MessageBox.Show("Error With Search " & searcherror.Message) Catch ex As Exception MessageBox.Show("Error : " & ex.Message) End Try


LinkBack URL
About LinkBacks
Reply With Quote
