Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 26-Nov-12 20:01pm
Edited 26-Nov-12 20:50pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In that Argument try something like this
param.ParameterName =Convert.ToDouble("");
  Permalink  
Comments
ruby kaur at 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.
kulasekaran-M at 27-Nov-12 4:05am
   
try
param.SqlDbType = SqlDbType.VarChar; instead of param.SqlDbType = SqlDbType.Float;
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As per your error message 4th parameter is @EMD_Amount, Convert that variable String to Double.
 
EX. Convert.ToDouble("@EMD_Amount");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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);
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid