Hy,
I have wrote in asp.net the next code:
And i get the message: Successful connection! Error Incorrect syntax near ','
I looked many times but I can not figure out what's wrong
Please help me
I have wrote in asp.net the next code:
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { TextBoxData.Text = Calendar1.SelectedDate.ToString(); } protected void Button1_Click(object sender, EventArgs e) { try { string connString = "Initial Catalog=PEOPLE;Data Source=John-4E29FADEE;Integrated Security=SSPI;"; SqlConnection conn = new SqlConnection(connString); conn.Open(); Response.Write("Successful connection!"); SqlCommand comanda = new SqlCommand(); comanda.Connection = conn; comanda.CommandType = System.Data.CommandType.Text; comanda.CommandText = "INSERT INTO dbo.PERSON VALUES (" + TextBoxID.Text + "," + TextBoxName.Text + "," + TextBoxInitiala.Text + "," + TextBoxLastName.Text + "," + TextBoxData.Text + "," + TextBoxCNP.Text + "," + TextBoxMother.Text + "," + TextBoxFather.Text + ")"; int no = comanda.ExecuteNonQuery(); Response.Write("No of affected rows = " + no); conn.Close(); } catch (SqlException exc) { Response.Write("Error " + exc.Message); } } }
I looked many times but I can not figure out what's wrong
Please help me
Comment