dim data as recordset = DB.Sqlselect("Select * from something")
Now I go through every record in the Recordset (data) and check some things in It, what’s not possible to check with a sql-statement:
If data <> Nil Then
While Not data.EOF
'check something
data.MoveNext
Wend
end if
If I find a record, what does not support the things I checked, I want to delete it. I thought it works with data.deleterecord - but nothing happend. Also not if I try to change a field-value in the current record like data.idxfield(1).stringvalue = "something other"
Background: After selecting and delete some records, I put the data in to a HTML-table to print and save the selected query-result.
Question:
how can I delete a record and edit a field in a recordset? What’s my problem?
Try “select rowid, * from something”. The query needs to include the integer primary key from the table in order for the middleware (Database API) to get delete and update to work. “rowid” is an implicit primary key in SQLite. Many experienced SQLIte users feel that it’s always better to explicitly declare your own primary key for a table. I’ll leave that for another discussion.
hello Kem please help me this is my code to make a database in mysql, but i really need to know how can i do to delete one record from my database. could yo help me please?
Dim db As New MySQLCommunityServer
Dim rs As RecordSet
If rs <> Nil Then
While Not rs.EOF
Listbox1.AddRow “”
ListBox1.Cell(Listbox1.LastIndex,0) = rs.Field(“Nombre”).StringValue
ListBox1.Cell(Listbox1.LastIndex,1) = rs.Field(“Apellidos”).StringValue
[quote=175507:@Orlando Alejandro Valencia Quiroz]hello Kem please help me this is my code to make a database in mysql, but i really need to know how can i do to delete one record from my database. could yo help me please?
[/quote]
You would use a SQL DELETE command
See http://dev.mysql.com/doc/refman/5.0/en/delete.html
db.sqlexecute("DELETE FROM usario WHERE MyAutoIncrementField = XX")
You should have an ID or AutoIncrement field to uniquely identify each record. If not, figure out what combination of fields uniquely identifies the record and use those in the WHERE clause.