This code is causing an error:
Incorrect syntax near the keyword 'table'
This error occurs on line 31:
cmd.ExecuteNonQuery();
This line gets highlighted what changes should I make in registration form
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class registration_page : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True");
{
con.Open();
SqlCommand cmd = new SqlCommand(@"insert into dbo.table(first name, last name, email, password, confirm password, gender) values ('" + Username.Text + "','" + Password.Text + "','" + contact.Text + "','" + gender.Text + "','" + email.Text + "' ,);");
Username.Text = "";
Password.Text = "";
contact.Text = "";
gender.Text = "";
email.Text = "";
// Assign the connection to command
cmd.Connection = con;
// Change the command variable name here
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Seamus O'Leary
, orRobert'); DROP TABLE Students;--
registers. See bobby-tables.com – Caius Jard