Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Getting error on insert page. i am enclosing my code of both pages aspx.cs and bussiness logic page and error. please help me out. Thanx in advance

Aspx.cs page on insert

protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (objSaleSanctionDetails.Insert(Convert.ToInt64(Session["SaleSanctionID"].ToString()), txtlotno.Text, txtsaleprice.Text, txtemd.Text, txtremsp.Text, txtvat.Text, txtfcess.Text,txttotal.Text))
        {
            lblStatus.Text = Resources.Language.Common_Record_Add;
        }
        BindGrid(Session["Language"].ToString());
       
    }

Bussiness logic page
clsSaleSanctionDetails.cs


public class clsSaleSanctionDetails
    {
        public clsSaleSanctionDetails()
        {
        }

        public bool Insert(long SaleSanctionID, string LotNo, Double SalePrice, Double EMD_Amount, Double RemainingSalePrice, Double VAT, Double ForestDepartmentCess, Double Total)
        {
            bool res = false;
            System.Collections.ArrayList sel = new System.Collections.ArrayList();

            sel.Add("SP_tr_Sale_SanctionDetails_Insert");
            ArrayList lstParam = new System.Collections.ArrayList();

            SqlParameter param;

            param = new SqlParameter();
            param.ParameterName = "@SaleSanctionID";
            param.SqlDbType = SqlDbType.BigInt;
            param.Value = SaleSanctionID;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@LotNo";
            param.SqlDbType = SqlDbType.VarChar;
            param.Value = LotNo;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@SalePrice";
            param.SqlDbType = SqlDbType.Float;
            param.Value = SalePrice;
            lstParam.Add(param);

        
            param = new SqlParameter();
            param.ParameterName = "@EMD_Amount";
            param.SqlDbType = SqlDbType.Float;
            param.Value = EMD_Amount;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@RemainingSalePrice";
            param.SqlDbType = SqlDbType.Float;
            param.Value = RemainingSalePrice;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@VAT";
            param.SqlDbType = SqlDbType.Float;
            param.Value = VAT;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@ForestDepartmentCess";
            param.SqlDbType = SqlDbType.Float;
            param.Value = ForestDepartmentCess;
            lstParam.Add(param);

            param = new SqlParameter();
            param.ParameterName = "@Total";
            param.SqlDbType = SqlDbType.Float;
            param.Value = Total;
            lstParam.Add(param);

            

            res = new eAuctionDAL.SQLDAL().UpdateTransData(sel, lstParam, false);
            return res;

        }

Error 7 Argument '4': cannot convert from 'string' to 'double'
D:\testing data\EAuction\SaleSanctionDetails.aspx.cs 117 132 D:\testing data\EAuction\
Posted
Updated 26-Nov-12 20:50pm
v2

check the @SaleSanctionID data type in SP

param = new SqlParameter();
param.ParameterName = @SaleSanctionID;
param.SqlDbType = SqlDbType.long;// use the same datatype
param.Value = SaleSanctionID;
lstParam.Add(param);
 
Share this answer
 
As per your error message 4th parameter is @EMD_Amount, Convert that variable String to Double.

EX. Convert.ToDouble("@EMD_Amount");
 
Share this answer
 
In that Argument try something like this
param.ParameterName =Convert.ToDouble("");
 
Share this answer
 
Comments
ruby kaur 27-Nov-12 2:31am    
if i am trying to do this getting error;
Error 60 Cannot implicitly convert type 'double' to 'string' .

and its not giving error here but on btn add button block.
kevin_ze 27-Nov-12 4:05am    
try
param.SqlDbType = SqlDbType.VarChar; instead of param.SqlDbType = SqlDbType.Float;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900