I've a windows form containing Id,GroupName,MemberName,Date,InstallmentAmount.
when I'm adding data to database it shows
"Incorrect Syntax near '1000'."(1000 is the amount of installment which I inserted in textbox.)
In database type of this field is numeric(8,2).
I'm not understanding why I'm getting this error. Please Help.
Here is my code:
private void btnSAdd_Click(object sender, EventArgs e)
{
cmbSGID = Convert.ToInt16(cmbSGrpName.SelectedValue);
cmbSMId=Convert.ToInt32(cmbSMName.SelectedValue);
SavingsDetails sd = new SavingsDetails(lblSTId.Text,cmbSGID,cmbSMId,dtpInstallmentDate.Value.Date,Convert.ToInt32(txtInstallmentAmt.Text));
sd.Add();
setSavingsGridView();
resetSavingsDetails();
}
public SavingsDetails(string _STId, int _GId, int _MId, DateTime _SDate, int _Amt)
{
con = new Connection();
STId = Convert.ToInt16(_STId);
GId = _GId;
MId = _MId;
SDate = _SDate;
Amt = _Amt;
}
public void Add()
{
con.Execute("insert into tblSavingsDetails(STId,STDate,GId,MId,SavingInstallment) values("+ STId +","+ SDate.ToShortDateString() +","+ GId +","+ MId +","+ Amt +"");
}