Bobi B

Bobi B

  • NA
  • 476
  • 11.5k

when i am executing getting an error incorrect syntax near

Apr 1 2017 3:40 AM
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class forms : System.Web.UI.Page
{
public static string str = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ChitFund-DataBase.mdf;Integrated Security=True";
SqlConnection con = new SqlConnection(str);
SqlDataAdapter adpt = new SqlDataAdapter();
protected void Page_Load(object sender, EventArgs e)
{
regdate.Text = DateTime.Now.ToString("dd/MM/yyyy");
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlCommand cmdinser = new SqlCommand("insert into ChitFund-CustomerRegistration values('" + id.Text + "' , '" + name.Text + "','" + father.Text + "' , '" + DropDownList1.Text + "','" + occupation.Text + "','" + dob.Text + "' , '" + regdate.Text + "','" + phone.Text + "' , '" + aadhar.Text + "','" + email.Text + "','" + address.Text + "','" + pincode.Text + "','" + area.Text + "','" + district.Text + "','" + street.Text + "','" + state.Text + "','" + offname.Text + "','" + offaddress.Text + "','" + offstreet.Text + "','" + offpin.Text + "','" + offdistrict.Text + "','" + offstate.Text + "','" + nomname.Text + "','" + nomrelation.Text + "','" + nomphonenumber.Text + "','" + nomaddress.Text + "','" + nompincode.Text + "','" + nomdistrict.Text + "','0')", con);
cmdinser.CommandType = CommandType.Text;
adpt.SelectCommand = cmdinser;
DataTable dt = new DataTable();
adpt.Fill(dt);
ClientScript.RegisterStartupScript(this.GetType(), "s", "alert('Registered Successfully')", true);
}

Answers (4)