Problemer med at trække data ud fra en MySQL Database
Hej,Jeg prøver at trække en record ud af min mySQl database ved at køre database connectioenen i en fukntion men kan ikke få det til at virke.
Nogle ide'r?
Kode :
Imports MySql.Data.MySqlClient
Public Class frmKunder
Private Sub btnSogKunde_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSogKunde.Click
Dim SQL As String
Dim Mydata
Dim Data
Dim Kunde_ID
SQL = "Select Kunde_ID from kunder where Kunde_ID = 75803644;"
Mydata = DatabaseForbindelse(SQL)
Data = Mydata.Read()
lblResultat.Text = Data.Kunde_ID
End Sub
Private Sub frmKunder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function DatabaseForbindelse(ByVal sqlstring As String)
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=mitdom.dk; user id=root; password=rootkode; database=database_kundeportal"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "" & sqlstring & ""
Dim myCommand As New MySqlCommand()
Dim msg
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start(query)
myAdapter.SelectCommand = myCommand
Dim myData As OleDBDataReader
myData = myCommand.ExecuteReader()
'MessageBox.Show(myData.GetValues(msg))
Return myData
End Function
End Class
Jeg får følgende fejl :
Public member 'Kunde_ID' on type 'Boolean' not found.