Greetings again. I have another problem I do not seem to be able to solve. I am using a SQLite database with a table named Contacts. The first record in the table is defined as an integer, Primary Key, Autoincrement.
I know everyone is going to aske why I don't use the built in rowID but there are very good reasons that I do not want to do that. One being when SQLite gets to the rowID limit it uses old rowID's that are available. I cannot use them because I use my autoincrement as a record in subsequent tables.
Ok having said that, I have not been able to figure out how to add a new record in the Contacts table. I am using ExecNonQuery2 like the following code
There are a total of 20 fields in the table so I use 20 ?'s
I have tried using both the EMPTY and NOVALUE variables as well as NULL in the Array but I still get a type mismatch error
I have also tried using only 19 ?'s and no entry in the Array for the first field but then I get a field count error.
Any help here will be appreciated. All the empty fields will be entered as an update later in the program.
Thank you all
Richard S
Ontario Canada
I know everyone is going to aske why I don't use the built in rowID but there are very good reasons that I do not want to do that. One being when SQLite gets to the rowID limit it uses old rowID's that are available. I cannot use them because I use my autoincrement as a record in subsequent tables.
Ok having said that, I have not been able to figure out how to add a new record in the Contacts table. I am using ExecNonQuery2 like the following code
B4X:
Private EMPTY As String = " "
Private NOVALUE As String = ""
Query = "INSERT INTO Contacts VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
SQL1.ExecNonQuery2(Query, Array As String(NOVALUE, edtLastName.Text, edtFirstName.Text, EMPTY, edtStreet.Text, edtCity.Text, EMPTY, edtProvState.Text, edtCountry.Text, edtPhone.Text, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, False, EMPTY))
ToastMessageShow("Contact added", True)
ResultSet1.Close 'close the ResultSet, we don't it anymore
I have tried using both the EMPTY and NOVALUE variables as well as NULL in the Array but I still get a type mismatch error
I have also tried using only 19 ?'s and no entry in the Array for the first field but then I get a field count error.
Any help here will be appreciated. All the empty fields will be entered as an update later in the program.
Thank you all
Richard S
Ontario Canada