I am reading from a file and inserting values into my table. However i'm not inserting into all columns. I'm getting an overflow exception i can't place. The file content are such as:
Huseyin Sabirli 13/11/1978 Nicosia MBRh+ 05333768275 Kelebek Street, No:11, Taskinkoy, Nicosia, KKTC
the code for creating the table
c.CommandText = "CREATE TABLE patients (patientid AUTOINCREMENT PRIMARY KEY, firstlastname CHAR, birthdate CHAR, birthplace CHAR, gender CHAR, bloodtype CHAR, telnum long, address CHAR)";
the code for insertion is:
c.CommandText = "INSERT INTO patients (" +
"firstlastname, birthdate, birthplace, bloodtype, telnum, address" +
") VALUES ('" +
info.Substring(0, 15) + "', '" +
info.Substring(24, 10) + "', '" +
info.Substring(35, 9) + "', '" +
info.Substring(47, 5) + "', '" +
info.Substring(53, 11) + "', '" +
info.Substring(64) + "')";
c.ExecuteNonQuery();
The overflow exception is thrown at the line c.ExecuteNonQuery();
.
NOTE: the spacing in the actual file is different from that shown above. This explains the variant lengths in the substring function. Thanks