Hallo, bekomme MySqlDataAdapter einfach nicht definiert und finde keine andere Lösung meine Daten in ein DataGridView zu importieren. Kann mir wer erklären wie ich das entweder definieren kann oder wie man es anders lösen könnte. MySql.Data.MySqlClient ist bereits Importiert.
Bin Anfänger und möchte für mich etwas erstellen.
Danke schonmal
Bin Anfänger und möchte für mich etwas erstellen.
Danke schonmal
VB.NET-Quellcode
- Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
- Dim MysqlConn As MySqlConnection
- Dim ContactsCommand As New MySqlCommand
- Dim ContactsAdapter As New MySqlDataAdapter
- Dim ContactsData As New DataTable
- Dim SQL As String
- MysqlConn = New MySqlConnection()
- ' Define the SQL to grab data from table.
- SQL = "SELECT * FROM tbkunden"
- 'Connection String
- MysqlConn.ConnectionString = "server=localhost;" _
- & "user id=root;" _
- & "password=;" _
- & "database=dbcarby"
- ' Try, Catch, Finally
- Try
- MysqlConn.Open()
- ContactsCommand.Connection = MysqlConn
- ContactsCommand.CommandText = SQL
- ContactsAdapter.SelectCommand = ContactsCommand
- ContactsAdapter.Fill(ContactsData)
- DataGridView1.DataSource = ContactsData
- Catch myerror As MySqlException
- MessageBox.Show("Cannot connect to database: " & myerror.Message)
- Finally
- MysqlConn.Close()
- MysqlConn.Dispose()
- End Try
- End Sub