Note that there are some explanatory texts on larger screens.

plurals
  1. POCompiler Error Message: CS0029: Cannot implicitly convert type 'decimal' to 'string'
    primarykey
    data
    text
    <p>I use GridView and from this i want to insert update. I have done my job but when i use RchPaidAmt field with numeric data type the following message show: Compiler Error Message: CS0029: Cannot implicitly convert type 'decimal' to 'string'</p> <p><strong>Data Type</strong></p> <pre><code>RchID int RchAppID int RchCallDate datetime RchComments varchar(150) RchAttemptCall int RchReceivedParty varchar(50) RchPrmTaken int RchCNPrm int RchNxtPrmDate datetime RchPaidAmt numeric(18, 2) &lt;UpdateParameters&gt; &lt;asp:Parameter Name="RchAppID" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCallDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchComments" Type="String" /&gt; &lt;asp:Parameter Name="RchAttemptCall" Type="Int32" /&gt; &lt;asp:Parameter Name="RchReceivedParty" Type="String" /&gt; &lt;asp:Parameter Name="RchPrmTaken" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCNPrm" Type="Int32" /&gt; &lt;asp:Parameter Name="RchNxtPrmDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchPaidAmt" Type="Decimal" /&gt; &lt;/UpdateParameters&gt; protected void GVCallHistory_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Add") { string strRchAppID = hfRchAppID.Value; string strRchCallDate = DateTime.Parse(Convert.ToString(DateTime.Now)).ToString("dd MMM yyyy HH:MM"); string strRchComments = ((e.CommandSource as Button).NamingContainer.FindControl("txtRchComments") as TextBox).Text; string strRchAttemptCall = ((e.CommandSource as Button).NamingContainer.FindControl("txtRchAttemptCall") as TextBox).Text; string strRchReceivedParty = ((e.CommandSource as Button).NamingContainer.FindControl("DDLRchReceivedParty") as DropDownList).SelectedValue; string strRchPrmTaken = ((e.CommandSource as Button).NamingContainer.FindControl("txtRchPrmTaken") as TextBox).Text; string strRchCNPrm = ((e.CommandSource as Button).NamingContainer.FindControl("txtRchCNPrm") as TextBox).Text; string strRchNxtPrmDate = ""; if (Convert.ToString(((e.CommandSource as Button).NamingContainer.FindControl("txtRchNxtPrmDate") as TextBox).Text) !="") { strRchNxtPrmDate = DateTime.Parse(Convert.ToString(((e.CommandSource as Button).NamingContainer.FindControl("txtRchNxtPrmDate") as TextBox).Text)).ToString("dd MMM yyyy"); } else { strRchNxtPrmDate = "01Jan1900"; } **string strRchPaidAmt = ((e.CommandSource as Button).NamingContainer.FindControl("txtRchPaidAmt") as TextBox).Text;** DSCallHistory.InsertParameters["RchAppID"].DefaultValue = DateTime.Parse(Convert.ToString(DateTime.Now)).ToString("dd MMM yyyy HH:MM");// strRchAppID; DSCallHistory.InsertParameters["RchCallDate"].DefaultValue = strRchCallDate; DSCallHistory.InsertParameters["RchComments"].DefaultValue = strRchComments; DSCallHistory.InsertParameters["RchAttemptCall"].DefaultValue = strRchAttemptCall; DSCallHistory.InsertParameters["RchReceivedParty"].DefaultValue = strRchReceivedParty; DSCallHistory.InsertParameters["RchPrmTaken"].DefaultValue = strRchPrmTaken; DSCallHistory.InsertParameters["RchCNPrm"].DefaultValue = strRchCNPrm; DSCallHistory.InsertParameters["RchNxtPrmDate"].DefaultValue = strRchNxtPrmDate; **if (strRchPaidAmt !=null) { DSCallHistory.InsertParameters["RchPaidAmt"].DefaultValue = Convert.ToDecimal(strRchPaidAmt); } else { DSCallHistory.InsertParameters["RchPaidAmt"].DefaultValue ="0"; }** DSCallHistory.Insert(); } } what should I do. Pls suggest me with best solution. Thanks Nur </code></pre> <blockquote> <p>Additional Information</p> </blockquote> <pre><code> &lt;asp:SqlDataSource ID="DSCallHistory" runat="server" ConflictDetection="CompareAllValues" ConnectionString="&lt;%$ ConnectionStrings:OptimaWebCustomerQueryCon %&gt;" DeleteCommand="DELETE FROM [TblRecCallHistory] WHERE [RchID] = @RchID" InsertCommand="INSERT INTO [TblRecCallHistory] ([RchAppID], [RchCallDate], [RchComments], [RchAttemptCall], [RchReceivedParty], [RchPrmTaken], [RchCNPrm], [RchNxtPrmDate], [RchPaidAmt]) VALUES (@RchAppID, @RchCallDate, @RchComments, @RchAttemptCall, @RchReceivedParty, @RchPrmTaken, @RchCNPrm, @RchNxtPrmDate, @RchPaidAmt)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [RchID], [RchAppID], [RchCallDate], [RchComments], [RchAttemptCall], [RchReceivedParty], [RchPrmTaken], [RchCNPrm], [RchNxtPrmDate]=(case when [RchNxtPrmDate] = '01Jan1900' then NULL else [RchNxtPrmDate] end), [RchPaidAmt] FROM [TblRecCallHistory] WHERE ([RchAppID] = @RchAppID) ORDER BY [RchID]" UpdateCommand="UPDATE [TblRecCallHistory] SET [RchAppID] = @RchAppID, [RchCallDate] = @RchCallDate, [RchComments] = @RchComments, [RchAttemptCall] = @RchAttemptCall, [RchReceivedParty] = @RchReceivedParty, [RchPrmTaken] = @RchPrmTaken, [RchCNPrm] = @RchCNPrm, [RchNxtPrmDate] = @RchNxtPrmDate, [RchPaidAmt] = @RchPaidAmt WHERE [RchID] = @RchID"&gt; &lt;DeleteParameters&gt; &lt;asp:Parameter Name="RchID" Type="Int32" /&gt; &lt;/DeleteParameters&gt; &lt;InsertParameters&gt; &lt;asp:Parameter Name="RchAppID" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCallDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchComments" Type="String" /&gt; &lt;asp:Parameter Name="RchAttemptCall" Type="Int32" /&gt; &lt;asp:Parameter Name="RchReceivedParty" Type="String" /&gt; &lt;asp:Parameter Name="RchPrmTaken" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCNPrm" Type="Int32" /&gt; &lt;asp:Parameter Name="RchNxtPrmDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchPaidAmt" Type="Decimal" /&gt; &lt;/InsertParameters&gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID="GVRecList" Name="RchAppID" PropertyName="SelectedValue" Type="Int32" /&gt; &lt;/SelectParameters&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name="RchAppID" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCallDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchComments" Type="String" /&gt; &lt;asp:Parameter Name="RchAttemptCall" Type="Int32" /&gt; &lt;asp:Parameter Name="RchReceivedParty" Type="String" /&gt; &lt;asp:Parameter Name="RchPrmTaken" Type="Int32" /&gt; &lt;asp:Parameter Name="RchCNPrm" Type="Int32" /&gt; &lt;asp:Parameter Name="RchNxtPrmDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="RchPaidAmt" Type="Decimal" /&gt; &lt;/UpdateParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload