TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anil Kumar
712
1.3k
134.2k
Column name or number of supplied values does not match
Jan 4 2013 2:40 PM
Hi..please solve my query
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
<form id="form1" runat="server">
<div>
<table align="center">
<tr>
<td>
<asp:Label ID="lblfname" runat="server" Text="First Name:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtfname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="validate1" runat="server"
ControlToValidate="txtfname" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblLname" runat="server" Text="Last Name"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtlname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtlname" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblemail" runat="server" Text="Email"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtemail" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblpass" runat="server" Text="Password"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtpass" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtpass" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblconpass" runat="server" Text="Confirm Password"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtconpass" runat="server" TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtpass" ControlToValidate="txtconpass"
ErrorMessage="Password mismatch"></asp:CompareValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbldesig" runat="server" Text="Designation"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtdesig" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtdesig" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbltexp" runat="server" Text="Total Exprience"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txttexp" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txttexp" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbldob" runat="server" Text="Date of Birth"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtdob" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtdob" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblmob" runat="server" Text="Mobile No:"></asp:Label>
:</td>
<td>
<asp:TextBox ID="txtmob" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtmob" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblresume" runat="server" Text="Resume"></asp:Label>
:</td>
<td>
<asp:FileUpload ID="fileup_resume" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="fileup_resume" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style1">
<asp:Button ID="btnsub" runat="server" Text="Submit" Width="86px"
onclick="btnsub_Click" style="margin-left: 21px" />
</td>
<td class="style1">
<asp:Button ID="btncan" runat="server" style="margin-left: 18px" Text="Cancil"
Width="77px" />
</td>
</tr>
</table>
</div>
</form>
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))
Reply
Answers (
1
)
Split function using sqlserver in asp.net
map in asp.net