To GIulio
Thanks for your suggestion.
Actually this I have solved, but it does not work properly.
Here my code:
[code] dim sql as String
if row=0 and Titellist.cell(0,1)<>"" then // The list is already filled and the toprow is empty.
Titellist.cell(0,0)=str(Titellist.Listcount) // in Column 0 are numbers, which are also in the database
sql = “INSERT into Titel (InvNr,Nr,Name) Values (”+ InvNr.text + “, " + Titellist.cell(0,0) + “, '” + fuerDB(Titellist.cell(0,1)) +”’)"
elseif row<>0 then // edited Data
if Titellist.cell(Titellist.listindex,1)<>"" then
sql = “UPDATE Titel SET Name = '”+fuerDB(Titellist.cell(Titellist.listindex,1))+"’ WHERE InvNr = “+InvNr.Text+” AND Nr = "+ Titellist.cell(Titellist.listindex,0)
else // if cell is empty delete in Database
sql = "DELETE from Titel WHERE InvNr = “+InvNr.Text+” AND Nr = "+ Titellist.cell(Titellist.listindex,0)
end if
end if
Sammler.SQLexecute(sql)
’
If Sammler.Error Then
MsgBox Sammler.ErrorMessage
Sammler.rollback
else
Sammler.Commit
end if
titelfill // In this routine all rows in listbox are deleted and then the listbox is filled with the values from database
[/code]
[code] SUB titelfill
Titellist.DeleteAllRows
Titellist.Addrow("")
Titellist.cell(0,1)=""
DIM sql as String
dim rs as RecordSet
if Suchtext1.text="" then
sql = “SELECT * FROM Titel where InvNr= " + InvNr.text + " ORDER BY Nr DESC”
else
sql = “SELECT * FROM Titel where InvNr= " + InvNr.text + " AND Name Like '%”+fuerDB(Suchtext1.Text)+"%’ ORDER BY Nr DESC"
end if
rs=Sammler.sqlselect(sql)
If Sammler.Error Then
MsgBox Sammler.ErrorMessage
end if
While NOT rs.EOF
Titellist.Addrow(rs.field(“Nr”).Stringvalue)
Titellist.Cell(Titellist.lastindex,1)=vonDB(rs.field(“Name”).Stringvalue)
rs.MoveNext
Wend
Titellist.CellType(0,1) = Listbox.TypeEditable
titellist.EditCell(0, 1)
[/code]
For me the thing, which I do not understand:
This routine “titelfill” is also used in the first event, when I come to this point, when I cellclick in another Listbox, to show this listbox:
[code] DIM sql as String
Dim p as Picture
dim rs as RecordSet
sql = "SELECT Bild FROM Sammlung where InvNr= " + InvNr.text
rs=Sammler.sqlselect(sql)
If Sammler.Error Then
MsgBox Sammler.ErrorMessage
end if
’
’
if (rs.Field(“Bild”).stringvalue)<>"" then
Dim s As String = decodebase64(rs.Field(“Bild”).stringvalue)
Dim mb As MemoryBlock = s
Imagewell1.image= p.FromData(mb)
End if
Titelfill[/code]