I have problem when inserting a date to my database
Insert query:
INSERT INTO users (f_name, s_name, t_name,family_name, age, national_id,
telephone, mobile, address, job_name, company_code, start_date, end_date)
VALUES (N'" + fname + "',N'" + sname + "',N'" + tname + "',N'" + famiy_name +
"',N'" + age + "',N'" + national_id + "',N'" + telephone +
"',N'" + mobile + "',N'" + address + "',N'" + job_name + "',N'" +
company_code + "'," + start_date + "," + end_date + ")";
Note the capital letter “N” before entries to be able to insert Arabic words
The error message:
Incorrect syntax near ’12’.
Although the date format from text visualizer is
05/11/2010 12:00:00 AM
I use VS2010 with DB sql express 2008
Use parameters instead of concatenation to build your query: