Whenever you get an error in a line like:
SqlCommand sqlcmd1 = new SqlCommand("INSERT INTO Instalment_Billing(" +
"ID,Pay_Date, Fees) VALUES (" + ID + "," + date + "," + a + ")", con);
you should immediately insert some code to print it out and check whether it's valid SQL:
Console.WriteLine ("INSERT INTO Instalment_Billing(" +
"ID,Pay_Date, Fees) VALUES (" + ID + "," + date + "," + a + ")");
or:
System.Windows.Forms.MessageBox.Show("INSERT INTO Instalment_Billing" +
"(ID,Pay_Date, Fees) VALUES (" + ID + "," + date + "," + a + ")");
This should show you exactly where your problem lies. Most likely insertions of dates should use strings of the format 'yyyy.mm.dd'
or something similar so you should, at a bare minimum:
- quote the date string (
... + ",'" + date + "'," + ...
).
- ensure that its format is okay (I'm not sure what
ToString()
will give you off the top of my head but I would think, given that you posted this today and it's not the tenth month or tenth day of the month, that it's probably something like yy-mm-dd
and the unquoted 10 from 2010 is causing you grief).