CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.

YesSoftware Forums -> CodeCharge -> Programming

 JSP error

Print topic Send  topic

Author Message
Posted: 12/02/2005, 3:43 AM

how to solve this error i have been getting when inserting data into MySQL database using JSP.

"Column count doesn't match value count at row 1"

My code is:

<%@ include file="allpkge.jsp" %>
response.addDateHeader("Expires",1 );
<html><head><title>Create Confirmation</title></head>
<body bgcolor="#FFFFFF">
<%@ include file="adminindex.html" %><br>
<div align=center><font face="Arial" size="3" color="chocolate">

Connection dbcon;
PreparedStatement ps;
ResultSet rs;
Statement stmt;

dbcon = DriverManager.getConnection("localhost","username","password");

String r1 = request.getParameter("txtempno");
String var1 = r1.trim();
String r2 = request.getParameter("txtcountry");
String var2 = r2.trim();
String r3 = request.getParameter("txtloc");
String var3 = r3.trim();
String r4 = request.getParameter("txtdept");
String var4 = r4.trim();
String r5 = request.getParameter("txtdesg");
String var5 = r5.trim();
String r6 = request.getParameter("txtfirst");
String var6 = r6.trim();
String from = request.getParameter("FROM_DATE");
String varfrom = from.trim();
String to = request.getParameter("TO_DATE");
String varto = to.trim();
String r7 = request.getParameter("txtemailid");
String var7 = r7.trim();
String r8 = request.getParameter("txtextno");
String var8 = r8.trim();
String r9 = request.getParameter("txtpsi");
String var9 = r9.trim();
String r10 = request.getParameter("txtcontact1");
String var10 = r10.trim();
String r11 = request.getParameter("txtcontact2");
String var11 = r11.trim();
String dec = "select * from empsearch where empno like '"+var1+"'";
String v1 = new String();

SimpleDateFormat df = new SimpleDateFormat("");
Date d = df.parse(varfrom);

v1 = rs.getString(1);
String s1="insert into empsearch values('"+var1+"','"+var2+"','"+var3+"','"+var4+"','"+var5+"','"+var6+"','"+varfrom+"','"+varto+"','"+var7+"','"+var8+"','"+var9+"','"+var10+"','"+var11+"')";
else if(var7.equals(""))
String s1="insert into empsearch values('"+var1+"','"+var2+"','"+var3+"','"+var4+"','"+var5+"','"+var6+"','"+varfrom+"','"+varto+"''"+var7+"','"+var8+"','"+var9+"','"+var10+"','"+var11+"')";
out.println("This Employee number already exists!");
%> </font><font face="Arial" size="3" color="#008080">

<B>Code '<%= var1 %>' has been created.</B></font></div>
<p> </p><p> </p><p> </p><p> </p>

<!-- SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date d = sdf.parse(varfrom);
Date sqlDate = new java.sql.Date(d.getTime());
String k = sdf.format(sqlDate);

Date fDate= new Date();
int a_dt = fDate.getDate();
int a_mn = fDate.getMonth();
int a_yr = fDate.getYear();

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.