Not updating the data so please rectify this error
Not updating the data so please rectify this error.I am using 3 tier archeiture the error occurs in dates format so please rectify how to passing parameters in C# using MS_Access Database.In MS_Access Database
//Code for Presentation Layer
BOL.bolIncomeType obj = new PayRoll.BOL.bolIncomeType();
obj.IncomeTypes = txtIncomeType.Text;
obj.Amount = Convert.ToDecimal(txtAmount.Text);
obj.INotes = txtrnote.Text;
obj.IncomeDate = Convert.ToDateTime(dtp1.Value.ToShortDateString());
obj.IncomeId = Convert.ToInt16(txtincomeid.Text);
obj.update();
txtincomeid.Text = dbConnection.GetNextNumber("IncomeType", "IncomeId").ToString();
MessageBox.Show("Record Updated sucessfully", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information );
// Code for Business layer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PayRoll.BOL
{
class bolIncomeType
{
DAL.dalIncomeType dalObj= new PayRoll.DAL.dalIncomeType();
private Int32 m_Srlno;
private Int32 m_Id;
private string m_Incometype;
private Decimal m_Amount;
private DateTime m_IncomeDate;
private string m_note;
/// <constructor>
/// Constructor bolIncomeType
/// </constructor>
public bolIncomeType()
{
//Initialize the variable here
}
/// <summary>
/// ColumnName:Srlno
/// Data Type:int
/// Length:0
/// </summary>
public Int32 SrlNo
{
get
{
return m_Srlno;
}
set
{
m_Srlno = value;
}
}
public Int32 IncomeId
{
get
{
return m_Id;
}
set
{
m_Id = value;
}
}
/// <summary>
/// ColumnName:Incometype
/// Data Type:VarChar
/// Length:50
/// </summary>
public string IncomeTypes
{
get
{
return m_Incometype;
}
set
{
if (value == "")
{
throw new InvalidData("Please enter IncomeType", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 50)
{
throw new InvalidData("The Incometype is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_Incometype = value;
}
}
/// <summary>
/// ColumnName:Amount
/// Data Type:decimal
/// Length:0
/// </summary>
public Decimal Amount
{
get
{
return m_Amount;
}
set
{
if (value == 0)
{
throw new InvalidData("Please enter the amount", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
m_Amount = value;
}
}
public DateTime IncomeDate
{
get
{
return m_IncomeDate;
}
set
{
m_IncomeDate = value;
}
}
public string INotes
{
get
{
return m_note;
}
set
{
if (value == "")
{
throw new InvalidData("Please enter Note", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 50)
{
throw new InvalidData("The Incometype is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_note= value;
}
}
public bool Insert ()
{
dalObj.Insert(this);
return true;
}
public bool update()
{
dalObj.Update(this);
return true;
}
}
}
// Code for Data Access layer
dbConnection conn =new dbConnection();
string sql = "update IncomeType set IncomeTypes=@IncomeType,Amount=@Amount,IncomeDate=@IncomeDate,INotes=@Note where IncomeId=@IncomeId";
OleDbParameter[] oleDbParameters = new OleDbParameter[5];
oleDbParameters[0] = new OleDbParameter("@IncomeId", OleDbType.Decimal);
oleDbParameters[0].Value = obj.IncomeId;
oleDbParameters[1] = new OleDbParameter("@IncomeType", OleDbType.VarChar);
oleDbParameters[1].Value = obj.IncomeTypes;
oleDbParameters[2] = new OleDbParameter("@Amount", OleDbType.Decimal);
oleDbParameters[2].Value = obj.Amount;
oleDbParameters[3] = new OleDbParameter("#@IncomeDate#", OleDbType.Date);
oleDbParameters[3].Value = obj.IncomeDate;
oleDbParameters[4] = new OleDbParameter("@Note", OleDbType.VarChar);
oleDbParameters[4].Value = obj.INotes;
return conn.executeUpdateQuery(sql, oleDbParameters);
// Code for dbconnection
OleDbCommand myCommand = new OleDbCommand();
try
{
//OleDbCommand myCommand = new OleDbCommand(_query,conn);
//myCommand.Parameters.AddRange(sqlParameter);
//conn.Open();
//myCommand.ExecuteNonQuery();
myCommand.Connection = openConnection();
myCommand.CommandText = _query;
myCommand.Parameters.AddRange(sqlParameters);
//myAdapter.UpdateCommand = myCommand;
myCommand.ExecuteNonQuery();
}
catch (OleDbException e)
{
Console.Write("Error - Connection.executeUpdateQuery - Query: " + _query + " \nException: " + e.StackTrace.ToString());
MessageBox.Show("Error while updating... " + e.Message);
return false;
}
finally
{
}
return true;