Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,
I am in dilemma with this problems,I have a front end application that have a page,so far it was working well,now unfortunately not work,then I found out this problem

<Command parameter[19] '' data value could not be converted for reasons other than sign mismatch or data overflow. >

I will test all possible data conversion but not getting exactly what happened
the code bellow
try
       {

           string strSql = "select ASSET_NAME,ASSET_TYPE_ID,QTY,UNIT_ID,UNIT_COST,ACQUISITION_DATE,RATE_OF_DEPRE,ASSET_COST,ACQUISITION_COST,ACQUISITION_EXPENSE,INSTALLATION_COST,BOOK_VALUE,DEPRECIABLE_COST,TOTAL_DEPRE_CHARGED,SALVAGE_VALUE,IDENTIFICATION_MARK,USEFUL_LIFE_YEAR,DEPT_ID,VENDOR_ID,DESCRIPTION,PARTICULARS,FIRST_YEAR_DEPRE_RATE,INITIAL_DEPRE_AMT,COST_VOUCHER_NO,TOTALASSETCOST,ASSETNO,CMP_BRANCH_ID,MEETINGNO from AT_ASSET_MASTER";
           DataRow oOrderRow;
           OleDbConnection conn = new OleDbConnection(strConString);
           DataSet oDs = new DataSet();
           OleDbDataAdapter oDbAdapter = new OleDbDataAdapter(new OleDbCommand(strSql, conn));
           OleDbCommandBuilder oDbCmdBuilder = new OleDbCommandBuilder(oDbAdapter);
           oDbAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
           oDbAdapter.Fill(oDs, "AT_ASSET_MASTER");
           // Insert the Data
           oOrderRow = oDs.Tables["AT_ASSET_MASTER"].NewRow();
           oOrderRow["ASSET_NAME"] = AssetName;
           oOrderRow["ASSET_TYPE_ID"] = assetTypeID;
           oOrderRow["DESCRIPTION"] = AssetDescription;
           oOrderRow["UNIT_ID"] = Unit;
           oOrderRow["IDENTIFICATION_MARK"] = IdentificationMarks;
           oOrderRow["ACQUISITION_DATE"] =Convert.ToDateTime(acquisitionDate);
           oOrderRow["VENDOR_ID"] = SupplierID;
           oOrderRow["DEPT_ID"] = DepartmentID;
           oOrderRow["QTY"] = qty;
           oOrderRow["UNIT_COST"] = Convert.ToDouble(unitCost);
           oOrderRow["TOTALASSETCOST"] =Convert.ToDouble(totalCost);
           oOrderRow["ACQUISITION_EXPENSE"] = Convert.ToDouble(AcquisitionExpense);
           oOrderRow["INSTALLATION_COST"] = Convert.ToDouble(InstallCost);
           oOrderRow["ASSET_COST"] = Convert.ToDouble(NetAssetCost);
           oOrderRow["COST_VOUCHER_NO"] = CostVoucherNo;
           oOrderRow["RATE_OF_DEPRE"] =DepreciationRate;
           oOrderRow["USEFUL_LIFE_YEAR"] = DepreciationLife;
           oOrderRow["DEPRECIABLE_COST"] = Convert.ToDouble(DepreciableCost);
           oOrderRow["BOOK_VALUE"] =Convert.ToDouble(BookValue);
           oOrderRow["SALVAGE_VALUE"] = Convert.ToDouble(SalvageValue);
           oOrderRow["MEETINGNO"] = strMeetingNO;
           //oOrderRow["INITIAL_DEPRE_AMT"] = FrstyrDepAmt;
           oOrderRow["ASSETNO"] = AssetNO;
           oOrderRow["CMP_BRANCH_ID"] = BranchID;
           oDs.Tables["AT_ASSET_MASTER"].Rows.Add(oOrderRow);
           oDbAdapter.Update(oDs, "AT_ASSET_MASTER");
       }
       catch (Exception ex)
       {

           return null;
       }

any help will be thankfully appreciate.
Mahmud
Posted

Check the type on one of the following lines (19th param):
C#
oOrderRow["USEFUL_LIFE_YEAR"] = DepreciationLife;
oOrderRow["DEPRECIABLE_COST"] = Convert.ToDouble(DepreciableCost);


Run in a debugger and check the object types.
 
Share this answer
 
Try and empty dataset as follows (add a where clause)

string strSql = "select ASSET_NAME,ASSET_TYPE_ID,QTY,UNIT_ID,UNIT_COST,ACQUISITION_DATE,RATE_OF_DEPRE,ASSET_COST,ACQUISITION_COST,ACQUISITION_EXPENSE,INSTALLATION_COST,BOOK_VALUE,DEPRECIABLE_COST,TOTAL_DEPRE_CHARGED,SALVAGE_VALUE,IDENTIFICATION_MARK,USEFUL_LIFE_YEAR,DEPT_ID,VENDOR_ID,DESCRIPTION,PARTICULARS,FIRST_YEAR_DEPRE_RATE,INITIAL_DEPRE_AMT,COST_VOUCHER_NO,TOTALASSETCOST,ASSETNO,CMP_BRANCH_ID,MEETINGNO from AT_ASSET_MASTER where 1=-1";
 
Share this answer
 

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