.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Unable to cast object of type 'System.Web.Mvc.ValueProviderResult' to type 'System.IConvertible'

Posted By:      Posted Date: August 23, 2010    Points: 0   Category :ASP.Net
 

Hello,
 Why am I getting this error on line:

               sp.Price = Convert.ToDecimal(collection.GetValue("Price"));

sp is :
  SPecials_Templates sp = new SPecials_Templates();

SPecials_Templates Defined:

    [MetadataType(typeof(SPecials_TemplatesMetaData))]
    public partial class SPecials_Templates
    {
        public class SPecials_TemplatesMetaData
        {

                [ScaffoldColumn(false)]
            public object Key { get; set; }
            [StringLength(50)]
            public object Template_Name { get; set; }
            [StringLength(12)]
            public object Headline { get; set; }
            [StringLength(12)]
    &nbs


View Complete Post


More Related Resource Links

Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'System.IConvertible'.

  

using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'

  
I'm repairing a custom cube being fed off a Dynamics AX 2009 instance. This particular named query looks like this: SELECT CUSTTABLE.ACCOUNTNUM, CUSTTABLE.CASHDISC, CUSTTABLE.SHIPCARRIERBLINDSHIPMENT, CUSTTABLE.PARTYTYPE, CUSTTABLE.PARTYID, CUSTTABLE.SHIPCARRIERACCOUNTCODE, CUSTTABLE.PROJPRICEGROUP, CUSTTABLE.SYNCENTITYID, CUSTTABLE.SYNCVERSION, CUSTTABLE.MEMO, CUSTTABLE.SALESDISTRICTID, CUSTTABLE.CURRENCY, CUSTTABLE.SEGMENTID, CUSTTABLE.SUBSEGMENTID, CUSTTABLE.COMPANYCHAINID, CUSTTABLE.MAINCONTACTID, CUSTTABLE.IDENTIFICATIONNUMBER, CUSTTABLE.PARTYCOUNTRY, CUSTTABLE.PARTYSTATE, CUSTTABLE.SALESGROUP, CUSTTABLE.BLOCKED, CUSTTABLE.ONETIMECUSTOMER, CUSTTABLE.ACCOUNTSTATEMENT, CUSTTABLE.CREDITMAX, CUSTTABLE.MANDATORYCREDITLIMIT, CUSTTABLE.DIMENSION, CUSTTABLE.DIMENSION2_, CUSTTABLE.DIMENSION3_, CUSTTABLE.NAME, CUSTTABLE.VENDACCOUNT, CUSTTABLE.TELEX, CUSTTABLE.PRICEGROUP, CUSTTABLE.MULTILINEDISC, CUSTTABLE.ENDDISC, CUSTTABLE.VATNUM, CUSTTABLE.COUNTRYREGIONID, CUSTTABLE.INVENTLOCATION, CUSTTABLE.DLVTERM, CUSTTABLE.DLVMODE, CUSTTABLE.ADDRESS, CUSTTABLE.MARKUPGROUP, CUSTTABLE.MBSFIRSTNAME, CUSTTABLE.MBSLASTNAME, CUSTTABLE.MBSMESSAGETEXT, CUSTTABLE.MBSNOBOALLOWED, CUSTTABLE.MBSCOLLECTORCODE, CUSTTABLE.MBSDLVROUTESEQ, CUSTTABLE.MBSBOALLOCATIONPRIORITY, CUSTTABLE.MBSCUSTEMOTION, CUSTTABLE.MBSPRICEFLOOR, CUSTTABLE.MBSPRICECEILING, CU

Unable to cast object of type 'System.Guid' to type 'System.String'.

  
protected void Button1_Click(object sender, EventArgs e) { using (BurnbetDataContext dc = new BurnbetDataContext()) { var q = (from c in dc.GetTable<tbl_Payment>() where c.ID == 5 select c).Single<tbl_Payment>(); dc.GetTable<tbl_Payment>().DeleteOnSubmit(q); dc.SubmitChanges(); } } }System.InvalidCastException was unhandled by user code  Message=Unable to cast object of type 'System.Guid' to type 'System.String'.  Source=System.Data.Linq  StackTrace:       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)&nb

Unable to cast object of type 'System.DBNull' to type 'System.String'.

  

 I saw lots of post about this issue. but haven't got good solution for that yet. Basically, what I did is that: I have a table in SQL database and some of data fields allow null. I built Objectdatasource through dataset. When I built update page using dataset. It generate the following error before showing the update page correctly. It seems I have issue to retrieve the null value from the database through using objectdatasource through dataset. Any suggestions?

 

Xinguo

 

Error attached below:

Unable to cast object of type 'System.DBNull' to type 'System.String'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

Source Error:

Line 1178:            get {
Line 1179:                try {
Line 1180:                    return ((string)(this[this.tablemember.CurrentCityStateColumn]));
Line 1181:                

Using IPC only channel getting Unable to cast object of type 'System.Runtime.Remoting.Identity' to

  

I have a remoting application that is using delegates to preform callbacks between processes. I found that if I don't use a TCP channel at all and only initialize an IPC channel that the callback delegates start throwing the following error after about a minute has passed.

From what little I could find on Google it seems to be a Lifetime Service management issue but all the classes that the delegates belong to return null from InitializeLifetimeService which should give the object an infinite lifetime.

With the TCP channel initialized the issue doesn't happen, but I would like it to use the IPC channel if all of the processes are on the local box.

 

Type:        System.InvalidCastException
Message:    Unable to cast object of type 'System.Runtime.Remoting.Identity' to type 'System.Runtime.Remoting.ServerIdentity'.
Stack Trace:   
Server stack trace:
   at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset' in BIDS

  
Hello.
I'm using BIDS for working with SSAS. I have bug with New Named Query feature.
Steps to reproduce:
1. Set up any data source.
2. Set up new data source view with any tables.
3. Right click on DSV body. Select 'New Named Query'
4. Switch to Generic Query Builder.
5. Type any query. For instance 'select name from sys.sysobjects'
6. Press Run button

After this message:
TITLE: Microsoft Visual Studio
------------------------------

An error occurred while reading data from the query result set.
Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-ADE5-00AA0044773D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

------------------------------
ADDITIONAL INFORMATION:

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-ADE5-00AA0044773D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). (System.Data)

---------

SPGridView Control: Paging Error - "Unable to cast object of type 'System.Int64' to type 'System.

  

Hello,

I'm creating project in VS 2010 using VisualWebPart. I'm using SPGridView for my grid in the web part. To acheive this, I've done following:

I added following xml in my ascx control

<SharePoint:SPGridView runat="server" ID="grdView" AutoGenerateColumns="false" AllowPaging="true" PageSize="2&

"Unable to cast object of type 'System.Windows.Controls.Expander' to type 'System.Windows.Control

  

Hello,

I Got This Error: "Unable to cast object of type 'System.Windows.Controls.Expander' to type 'System.Windows.Controls.GroupBox'"

 

In XAML file Code of Control Herarchy is like this

<GroupBox>

<DockPanel>

<ScrollViewer>

<DockPanel>

here i declare 10 Expander

<Expander 1>...<expander10>

and in each expander there is 1 <Grid> Control

</DockPanel> 

</ScrollViewer>

</DockPanel> 

</GroupBox>

Now my code is working fine....but problem is i want to remove Expander10

so i removed <Expander10> andrelated code from CS file.

codes compiled successfully. but when i Open this screen i got this error on InitializeComponent() and Error shows in XAML page.

is

"Unable to cast object of type 'System.Windows.Controls.Expander' to type 'System.Windows.Controls.GroupBox'"

Please Help me for this Error.

it's really strenge what's wrong in removing expander from herarchy......



Unable to cast object of type 'System.Data.DataSet' to type 'DataSet'.

  
Specifications : VS 2008 & SQL 2005 Express
Unable to cast object of type 'System.Data.DataSet' to type 'DataSet'.
I'm getting this error in cliend app, while passing values to the wcf service(iis),
WCF Sevice code
  public DataSet ListofAccounts(string custidno)
  {
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStrWestSideBank"].ConnectionString);
    SqlDataAdapter da = new SqlDataAdapter("select * from AccountDetails where vCustIdentityNo ='" + custidno + "'", con);
    DataSet ds = new DataSet();
    da.Fill(ds, "AccountDetails");
    return ds;
  }
I'm unable to get this, i tried in many ways but no use, please help me. Follwing is the code,of button click event 
   ServiceReference1.ServiceClient svcobj = new

Unable to cast COM oject of type 'System.__ComObject' to class type of 'System.Drawing.Bitmap' .

  
 private void DirectXViewer_DragDrop(object sender, DragEventArgs e)

  {

   mousePressedFlag = false;

   if(e.Data.GetDataPresent(typeof(Bitmap)))

   {

    Object obj = e.Data.GetData(typeof(Bitmap));

    

    {

     try

     {

      Bitmap image = (Bitmap)((Bitmap)obj).Clone();

      RenderImage = image;

      image.Dispose();

     }

     catch(Exception ex)

     {

      MessageBox.Show(ex.Message.ToString());

     }

    

    }

   }

  }

private void DirectXViewer_MouseMove(object sender, MouseEventArgs e)

  {



   if (mousePressedFlag)

   {

    if(cacheBitmap != null)

     this.DoDragDrop(new Bitmap(cacheBitmap), DragDropEffects.Copy);

    

   }

  }

Hi All,

I try to d

No mapping exists from object type System.Web.UI.WebControls.Label to a known managed provider nativ

  
 I'm making the leap to move from vb.net to C#, and I'm getting this crazy error when I try to execute one sp, set a value, and then execute another sp based on the value.   Any suggestions??? proc_GetSectionDetails is my first stored procedure.  From that, I get a value for SectionID, and then use it for the second sp called  proc_GetSectionDetails protected void getSectionContent() { SqlConnection conn = default(SqlConnection); SqlCommand comm = default(SqlCommand); SqlDataReader reader = default(SqlDataReader); string connectionString = ConfigurationManager.ConnectionStrings["123"].ConnectionString; conn = new SqlConnection(connectionString); comm = new SqlCommand(); comm.Connection = conn; comm.CommandType = System.Data.CommandType.StoredProcedure; comm.CommandText = "proc_GetSectionDetails"; comm.Parameters.AddWithValue("SubSectionID", Request.QueryString["SubSectionID"]); conn.Open(); reader = comm.ExecuteReader(); if (reader.Read()) { lblName.Text = Convert.ToString(reader["SubSectionName"]); lblDesc.Text = Convert.ToString(reader["SubSectionDescription"]); Label SubSectionParentID = new Label();

Unable to cast object of type problem

  
hi I'm having a problem in this code: Public Function GetChannelList() As List(Of channel) Implements IChannelService.GetChannelList         Dim db As ChannelDataContext = New ChannelDataContext         Dim channelMatch = From channelRow In db.channels _                           Join parentChild In db.ChannelParentChildListings _                           On channelRow.channel_id Equals parentChild.parent_id _                           Order By channelRow.title Ascending _                           Select channelRow.channel_id, channelRow.title, parentChild.child,   parentChild.child_id           Return channelMatch    <-------- Error throw Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_1`4[S

Cannot add content to object of type 'System.Windows.Navigation.NavigationWindow'

  
Hello, i'm trying to add content to a custom class inherited from System.Windows.Navigation.NavigationWindow but i receive the following error: Cannot add content to object of type 'System.Windows.Navigation.NavigationWindow' This is the XAML of my Window: <NavigationWindow x:Class="Obolus.Windows.MainWindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="..."     Style="{StaticResource MainWindowStyle}" ContentRendered="NavigationWindow_ContentRendered" >     <Grid></Grid>     </NavigationWindow> what i want is drawing shapes in this window, which will act as container and background for a lot of pages inside. It will be a classic Wizard. In .Net Windows Forms i override the OnPaint method of any control, and i draw all the things programatically. I don't know hot to do it in WPF. ¿Adding shape contents to the window? ¿overriding OnContentRendered? ¿any idea? Thanks in advance, Best regards, Raúl Truco,  

>>Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.

  

Hi,

I am trying to upload a picture into database using FormView insertItemTemplate. 

FormView is bounded by objectdatasource.

To upload, I placed FileUpload control inside insertItemTemplate.

In table the dataType is image.

Error:

Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.

Any swift reply would be appreciated. Thanks.

 


Object of type 'System.Int32' cannot be converted to type 'System.String

  

When i'm trying to update a table using dynamic data, i'm getting the following error. I was trying to google the solution for the whole day, but it didnt work. I tried to declare the type of parameters like this

<asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true"
                OnInserting="DetailsDataSource_Inserting"
                onselected="DetailsDataSource_Selected"
                onupdating="DetailsDataSource_Updating" > <UpdateParameters><asp:Parameter Name="PK_ID" Type="Int32" /><asp:Parameter Name="id" Type="Int32" />
                <asp:Parameter Name="c_titulu" Type="Int32" />
                <asp:Parameter Name="perio" Type="Int32" />
            

Unable to convert type System.String to System.Web.DynamicData.MetaTable

  

Hi,

I am encountering the problem  "Unable to convert type System.String to System.Web.DynamicData.MetaTable" when I hit one of the tables for List.aspx.  It is using the DynamicData/PageTemplates/List.aspx and this error is not happening in other tables.

It is happening on the line

GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));

If you have any leads, please let me know.

Thanks.

CC


No mapping exists from object type System.Xml.Linq.XDocument to a known managed provider native type

  

Hello,

I am using XML in getting client data in 3-tier architecture, using XDocument in passing XML among layers.

But when I use it in inserting this XML in XDocument, it throws the following error:

No mapping exists from object type System.Xml.Linq.XDocument to a known managed provider native type. 

I am using the following code, it throws the exception at the bold line:

 public void DALInsertXML(XDocument x)
        {
            SqlConnection connection = new SqlConnection(connection1);
            connection.Open();
            _command = ne
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend