Hi,
i am using vs2010 and mysql database, i am passing the 9 values to stored procedure and i am writing code using sqltransactions ,
Admin.aspx.cs (code)
btnAddCusInvoice_Click
oInvInvoiceLineItems.CustomerID = ddlCustomerName.SelectedValue;
oInvInvoiceLineItems.InvoiceID = Convert.ToInt32(txtCusInvNumber.Text);
DataSet local_ds = null;
string local_strStoredProcName;
int count = 0;
local_ds = new DataSet();
oInvHeader.CustomerID = ddlCustomerName.SelectedValue;
oInvHeader.InvoiceID = Convert.ToInt32(txtCusInvNumber.Text);
oInvHeader.Flag = "N";
local_strStoredProcName = "uspInvoiceFedTaxID";
oInvInvoiceLineItems.Select(out local_ds, local_strStoredProcName, ddlCustomerName.SelectedValue);
oInvHeader.FedTaxID = local_ds.Tables[0].Rows[0]["FedTaxID"].ToString();
oInvHeader.PaymentDate = DateTime.Now;`if (txtMemo.Text != string.Empty)
{
oInvHeader.Memo = txtMemo.Text;
}
else
{
oInvHeader.Memo = "Null";
}
oInvHeader.DueDate = DateTime.Now;
oInvHeader.Amount = Amount;
oInvInvoiceLineItems.TotalAmount = Amount;
MySqlTransaction oSqlTrans = null;
if (customer != null)
{
oInvInvoiceLineItems.Update(count, oSqlTrans);
}
else
{
oInvHeader.Add(oInvInvoiceLineItems, count, oSqlTrans);
}`
oInvHeader.cs(DAO)
write the code like this
public bool Add(InvInvoiceLineItems oInvoiceLineItems,int count, MySqlTransaction oSqlTran)
{
m_bFlag = false;
oSqlTran = null;
MySqlConnection oConn = new MySqlConnection(Utilities.ConnectionString());
string sTransName = "Invoice";
if (oConn.State != ConnectionState.Open)
{
oConn.Open();
}
oSqlTran = oConn.BeginTransaction();
try
{
if (this.Add(oSqlTran, oConn))
{
if (oInvoiceLineItems.Add(oSqlTran,count ,oConn))
{
oSqlTran.Commit();
}
}
}
catch (Exception ex)
{
oSqlTran.Rollback();
m_sbErrMsg.Length = 0;
m_sbErrMsg = Utilities.ErrorMessage(ex);
m_oErrlog.Add(m_sbErrMsg.ToString(), DateTime.Now);
throw;
}
finally
{
oConn.Close();
}
return this.m_bFlag;
}
public bool Add(MySqlTransaction oSqlTran, MySqlConnection oConn)
{
m_bFlag = false;
m_oCmd = new MySqlCommand("uspInvoiceHeaderAdd", oConn);
m_oCmd.CommandType = CommandType.StoredProcedure;
m_oCmd.Transaction = oSqlTran;
m_oCmd.Parameters.AddWithValue("_CustomerID", CustomerID);
m_oCmd.Parameters.AddWithValue("_InvoiceID", InvoiceID);
m_oCmd.Parameters.AddWithValue("_Amount", Amount);
m_oCmd.Parameters.AddWithValue("_PaymentDate", PaymentDate);
m_oCmd.Parameters.AddWithValue("_Documentype", Documentype);
m_oCmd.Parameters.AddWithValue("_Flag", Flag);
m_oCmd.Parameters.AddWithValue("_FedTaxID", FedTaxID);
m_oCmd.Parameters.AddWithValue("_Memo", Memo);
m_oCmd.Parameters.AddWithValue("_DueDate", DueDate);
if (m_oCmd.ExecuteNonQuery() > 0)
{
m_bFlag = true;
}
return this.m_bFlag;
}
so i am passing all values (CustomerID etc)but error is
(Incorrect Number of arguments for procedure uspInvoiceHeaderAdd;expected 9,got 6)
and i am using mysql 5.1 stored procedure is
CREATE DEFINER=`root`@`%` PROCEDURE `uspInvoiceHeaderAdd`(
_CustomerID VARCHAR(50),
_InvoiceID INT,
_Amount DECIMAL(18,2),
_PaymentDate DATETIME,
_Documentype INT,
_Flag NATIONAL CHAR(10),
_FedTaxID CHAR(9),
_Memo VARCHAR(50),
_DueDate DATETIME
)
BEGIN
insert into tblInvoiceHeader(CustomerID,InvoiceID,Amount,
PaymentDate,Documentype,Flag,FedTaxID,Memo,DueDate)
values(_CustomerID,_InvoiceID,_Amount,_PaymentDate,ifnull(_Documentype,0),_Flag,_FedTaxID,_Memo,_DueDate);
END
so what is the problem and how to solve the problem , any one pls help me
Thank's Hemanth