Sub btnEditAdd_Click
Dim row(NumberOfColumns) As String
Dim i, hh As Int
Dim txt As String
txt = "SELECT max(" & ColumnName(0) & ") FROM " & DBTableName
row(0) = SQL1.ExecQuerySingleResult(txt) + 1
'we set SELECT max( ColumnName(0)) FROM DBTableName equivalent to SELECT max(ID)FROM personsand get row(0)
txt = "INSERT INTO "&DBTableName&" VALUES (NULL"
For i = 1 To NumberOfColumns - 1
Dim e As EditText
e = scvEdit.Panel.GetView(i * 2 + 1)
row(e.Tag) = e.Text
txt = txt&" , '"&e.Text&"'"
If e.Text = "" Then
hh = hh + 1
End If
Next
txt = txt & ")"
'The final query text could look like this:
INSERT INTO persons VALUES(NULL, 'Jules', 'VERNE', 'Rue St.Honoré', 'Paris')
'The NULL value is entered for the autoincrement of the ID column.
If hh > 0 Then
Msgbox("There are "&hh&" data missing ","Attention")
Return
End If
'---------------------------------
'check for existing entry first
'SQl1.ExecQuery (Select * from "&DBTableName&" WHERE ColumnName1 = row(1) And ColumnName2 = (row2) ")
'@@ Only guessing at above statement !!
'if there is a Result then advise user and do not continue ...
'---------------------------------
'if entry not exists then .......
AddRow(row)
If NumberOfRows > 0 Then
btnEditModif.Visible = True
End If
'Then we call the AddRow(row) routine to add the new data set to the Scrollview.
'And set the Edit button to visible if there is at least one data set in the database.
SQL1.ExecNonQuery(txt)
'..............................
End Sub