Syntax error in INSERT INTO statement in c# oledb?

Posted by sameer on Stack Overflow See other posts from Stack Overflow or by sameer
Published on 2010-04-23T05:41:27Z Indexed on 2010/04/23 5:43 UTC
Read the original article Hit count: 167

Filed under:

I am having a table called SubMaster_Accounts, which contains 9 fields. In which I want to insert data to some fields and i want to store some other fields as NULL. I tried to write the query using query string, The sql query works perfectly when i insert the data for all the fields, but when i insert data as NULL to some of the fields it shows syntax error in Insert command. The fields which i want to insert as NULL are not constraints.

How can i do it?

This is my query string.

insert into SubMaster_Account ([SMcode], [MSname], [Sname], [Openbalrs], [Openbalrs1], [Openbalmet], [Openbalmet1], [Creditdays], [Sdesc]) values ('" + SMcode + "','" + MSname + "','" + Sname + "'," + Openbalrs + ",'" + Openbalrs1 + "'," + Openbalmet + ",'" + Openbalmet1 + "'," + Creditdays + ",'" + Sdesc + "')

© Stack Overflow or respective owner

Related posts about c#