i m getting problem in a sample jobseeker form when connection with database.
Column name or number of supplied values does not match table definition.
asp.net page
ControlToValidate="txtfname" ErrorMessage="*"> | |
: | ControlToValidate="txtlname" ErrorMessage="*"> |
: | ControlToValidate="txtemail" ErrorMessage="*"> |
: | ControlToValidate="txtpass" ErrorMessage="*"> |
: | ControlToCompare="txtpass" ControlToValidate="txtconpass" ErrorMessage="Password mismatch"> |
: | ControlToValidate="txtdesig" ErrorMessage="*"> |
: | ControlToValidate="txttexp" ErrorMessage="*"> |
: | ControlToValidate="txtdob" ErrorMessage="*"> |
: | ControlToValidate="txtmob" ErrorMessage="*"> |
: | ControlToValidate="fileup_resume" ErrorMessage="*"> |
onclick="btnsub_Click" style="margin-left: 21px" /> | Width="77px" /> |
C # 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 Job_application : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection("data source=PC\\SQLEXPRESS; user id=sa; password=password@123;initial catalog=Rohini;");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsub_Click(object sender, EventArgs e)
{
SqlCommand sqcom = new SqlCommand("select Email from jobseeker where Email='" + txtemail.Text.ToString().Trim() + "'", conn);
conn.Open();
SqlDataReader dr = sqcom.ExecuteReader();
string Email = "";
while (dr.Read())
{
Email = dr[0].ToString();
conn.Close();
}
if (Email == txtemail.Text.ToString().Trim())
{
//Label1.Visible = true;
// Label1.Text = "User alredy Exists please try with Other Email ID";
}
else
{
SqlConnection conn1 = new SqlConnection("data source=PC\\SQLEXPRESS; user id=sa; password=password@123;initial catalog=Rohini;");
conn1.Open();
SqlCommand scom = new SqlCommand("insert into Users values('" + txtfname.Text.ToString().Trim() + "','" + txtlname.Text.ToString().Trim() + "','" + txtemail.Text.ToString().Trim() + "','" + txtconpass.Text.ToString().Trim() + "','" + txtdesig.Text.ToString().Trim() + "','" + txttexp.Text.ToString().Trim() + "', '" + txtdob.Text.ToString().Trim() + "','" + txtmob.Text.ToString().Trim() + "')", conn1);
scom.ExecuteNonQuery();
conn1.Close();
txtemail.Text = "";
txtfname.Text = "";
txtlname.Text = "";
txtdesig.Text = "";
txttexp.Text = "";
txtmob.Text = "";
txtdob.Text = "";
fileup_resume.SaveAs(Server.MapPath("~/upload/" + fileup_resume.FileName));
}
}
}
database table
create table jobseeker(s_no int identity primary key,fname varchar(50),lname varchar(50),email varchar(100),conpass varchar(50),desig varchar(50),totlexp varchar(50),dob varchar(50),mob varchar(12),resume varchar(50))
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Bryian TanPosted Jan 9, 2013, 11:54 PM
I think it expecting the value for column resume. Is that column accepting null by default? You can try to pass in an empty string to that column for testing purpose to see if the error will go away.