Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim reader As OleDb.OleDbDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\datenbank.mdb"
cmd.Connection = con
Try
con.Open()
cmd.CommandText = "Select * from picture"
reader = cmd.ExecuteReader()
reader.Read()
PictureBox1.Location = reader("x, y") 'hier muss der Fehler sein!
'es wird eine MsgBox mit "x,y" angezeigt!?
reader.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End Sub
Public bButton As Boolean
Public bFirst As Boolean, iX As Integer, iY As Integer
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
bButton = True
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If bButton Then
If Not bFirst Then
bFirst = True
iX = e.X
iY = e.Y
End If
PictureBox1.Left = PictureBox1.Left + e.X - iX
PictureBox1.Top = PictureBox1.Top + e.Y - iY
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim anzahl As Integer
Try
con.Open()
cmd.CommandText = _
"update picture set " & _
"x = '" & iX & "', " & _
"y = '" & iY & "'"
'MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
bButton = False
bFirst = False
End Sub
End Class