w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
The cast to value type 'Int32' failed because the materialized value is null
It tells you right in there: The cast to value type 'Int32' failed because the materialized value is null. This is the offending line: ReleaseYear = (int) shows.ReleaseYear, Check your data and make sure everything has a ReleaseYear, or switch to using int?.

Categories : C#

Error :the cast to value type "Double" failed because the materialized value is null
And what about this? public int StarProduct(int id_Product) { return Convert.ToInt32(db .tbl_satar_Product .Where(p => p.Id_Product == id_Product && p.star.HasValue) .Average(s => s.star.Value)); }

Categories : C#

If strings are nullable by default, why do i get Unable to cast object of type 'System.DBNull' to type 'System.String'.?
Because null != DBNull.Value. But you can check if it the value in the DataReader is null with the IsDbNull method: DestributionGroup = dr.IsDbNull("Destribution Group") ? "" : dr.GetString("Destribution Group");

Categories : C#

Function to accept nullable type and return nullable type or string
static string MyFunction<T>(Nullable<T> arg) where T : struct { String strNULL = "NULL"; if (arg.HasValue) return arg.Value.ToString(); else return strNULL; }

Categories : C#

The type 'System.Data.Spatial.DbGeography' must be a non-nullable value type in order to use it as parameter 'T'
This was the solution that I found in the end after digging a bit further in to EF6 documentation. Removing assembly references to System.Data.Entity.dll Installing the EF6 NuGet package adds the following runtime assemblies to your project: Recent builds of the EF6 NuGet package removes reference to System.Data.Entity.dll from the project. EF6 doesn’t use any code from System.Data.Entity.dll and having it referenced in your project could cause build conflicts. These conflicts can be resolved but in general you should not be using EF6 and System.Data.Entity.dll in the same application. Hope this may help anyone else who faces the same issue.

Categories : Entity Framework

Mongo/DataNucleus/JPA with embedded type query gives: Cannot find type of (part of) ... since symbol has no type; implicit variable?
FINE: Compilation of filter to be evaluated completely in-datastore was impossible : Invoke expression is not supported by this mapper so it is not currently implemented to convert JPQL "collField.contains(val)" (the equivalent of what you typed in for your query) into a MongoDB query, hence cant evaluate it in the datastore. Since you know what it needs converting into, you can easily enough get the code for the DataNucleus MongoDB plugin and find class QueryToMongoDBMapper and contribute support for that particular query.

Categories : Mongodb

Is there a way to cast this enum to proper type
You can do this: void SetOptions() { DropDownList.Items.Clear(); var options = Enum.GetValues(ListType); // need to cast this to type of ListType foreach (var o in options) { var item = new ListItem(o.Description(), o.ToString()); item.Tag = o; DropDownList.Items.Add(item); } } Then you can get the type from the Tag property of whatever list item is selected.

Categories : C#

How to convert nullable type to its underlying type?
But it supports nullable types, AllowDbNull is true by default: var table = new DataTable(); table.Columns.Add("NullableInt", typeof(int)); table.Rows.Add(1); table.Rows.Add(2); table.Rows.Add(3); table.Rows.Add((int?)null); Use the DataRow extension methods which support nullable types, for example: foreach(DataRow row in table.Rows) { int? value = row.Field<Int32?>("NullableInt"); // modify the value with SetField: row.SetField<Int32?>("NullableInt", null); // or: row.SetField("NullableInt", (int?)null); }

Categories : Dotnet

Unable to cast object of type to type 'System.Data.Objects.ObjectContext
Try the link for MSDN Article below solved my problem when I was going through the same tutorial. MSDN Article! Just change SchoolContext to SchoolEntities in the method SchoolContextEntityDataSource_ContextCreating() Best regards, Adit Malik

Categories : Entity Framework

Oracle ODAC error setting up website in IIS: type A cannot be cast to type B?
Looks like an old version of the data access DLL is installed in the GAC. Does the DLL in c:windowsmicrosoft.net... exist? If not, you may have to provide a copy of it in a bin folder and update your config to use the DLL in the bin. This assumes you want to use the new version and not the old one in the GAC.

Categories : C#

Unable to cast object of type VB$AnonymousDelegate to type System.Func
"Function() to a Func" is not an implicit conversion precisely, but the normal assignation which Func expects (that is, a Function). You are not including the As Func(Of T, Boolean) bit in BoolFunc, what makes this function "anonymous" (you are not saying explicitly the returned type). Include this bit and it should work without any problem. That is, replace your BoolFunc with this one: Public Function BoolFunc(Of T)(ByVal bfunc As Func(Of Boolean, Boolean, Boolean), ByVal f1 As Func(Of T, Boolean), ByVal f2 As Func(Of T, Boolean)) As Func(Of T, Boolean) If f1 Is Nothing Then Return f2 If f2 Is Nothing Then Return f1 Return Function(param As T) bfunc(f1(param), f2(param)) End Function

Categories : Vb.Net

Unable to cast object of type 'System.Web.Security.SqlRoleProvider' to type 'WebMatrix.WebData.SimpleRoleProvider'
That's because SqlRoleProvider does not inherit SimpleRoleProvider. However, you can try using SimpleRoleProvider Constructor (RoleProvider): var roles = new SimpleRoleProvider(Roles.Provider);

Categories : Sql Server

How to cast a string value to some specific type when we have only Class object of the type?
According to what you describe, if you have: String var = "variable"; Class<?> type = Class.forName("your_class");// Your type Object o = type.cast(var); Now 3 things can happen: o should be of your_class type If var is null, o will be null or ClassCastException will be thrown

Categories : Java

Using weka in C#: Unable to cast object of type 'java.util.ArrayList' to type 'System.Collections.Generic.List`
I am answering my own question. I used this link to solve the problem I was facing. Thanks @SecretSquirrel(see the comments) and @Jon Iles (see the answer I've linked).

Categories : C#

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32'
You are expecting an id parameter in your URL but you aren't supplying one. Such as: http://yoursite.com/controller/edit/12 ^^ missing

Categories : C#

What does Failed to convert property value of type '$Proxy0 to required type means in this case?
Ok, first thing i see here: WriterSqlParameterSetter is a ItemPreparedStatementSetter! fine! But even if you declare: <beans:property name="amount" value="#{jobParameters[amount]}"/> <beans:property name="id" value="#{jobParameters[id]}"/> I don't see theses properties in : public class WriterSqlParameterSetter implements ItemPreparedStatementSetter<transactionas>{ public void setValues(transactionas ts, PreparedStatement ps) throws SQLException { ps.setDouble(1, ts.GetAmount()); ps.setInt(2, ts.GetID()); } } And even if the properties were declared, the ItemPreparedStatementSetter wont use them since, it takes value from the object received in the writer (eg. transactionas). I am trying to see why you need to pass an amount and

Categories : Spring

How to cast to an object to a type when type is known during runtime?
Unfortunately, it's not just that its the "same class in a different namespace"... basically, you have 2 classes. They are completely different classes, because of the auto generated code. As far as the .Net Runtime is concerned, they might as well be as different as "int" and "string". They probably even hail from different assemblies. I've had a similar issue as well - and at this point, probably the easiest thing you can do is make your own generic converter method that will read the public properties from the one type, and populate them on the another type. This can be done because you PROMISE that the two classes look identical :)

Categories : C#

What does Failed to convert property value of type '$Proxy0 to required type means?
You don't use the right interface. Your ReaderSqlParameterSetter should implements PreparedStatementSetter not ItemPreparedStatementSetter If you look at the impl of JdbcCursorItemReader: public class JdbcCursorItemReader<T> extends AbstractCursorItemReader<T> { PreparedStatement preparedStatement; PreparedStatementSetter preparedStatementSetter; String sql; RowMapper rowMapper; The property is a PreparedStatementSetter . If you look at the interface you try to use : public interface ItemPreparedStatementSetter<T> { /** * Set parameter values on the given PreparedStatement as determined from * the provided item. * @param ps the PreparedStatement to invoke setter methods on * @throws SQLException if a SQLException is encountered (i.e. there is no * need to

Categories : Spring

Why does JQuery NOT selector failed on Type Submit but works on Type Button
Your code does work, here: http://jsfiddle.net/AstDerek/s5cyk/ What do you expect to happen with the code you are using? Original answer: I don't really understand what your code does, but it seems you are trying to target a button with an :input selector, so your code doesn't work as you expect. Maybe this selector can do the job: $('#myForm :input:not(#btnSubmit), #myForm button:not(#btnSubmit)')

Categories : Javascript

While loop warns of always true since value of type 'int' is never equal to 'null' of type 'int'
while (upload.Peek() != null) ...looks suspicious since StreamReader.Peek() can't return null. I suspect the correct line would be; while (upload.Peek() != -1) Return Value Type: System.Int32 An integer representing the next character to be read, or -1 if there are no characters to be read or if the stream does not support seeking.

Categories : C#

Unable to cast object of type 'System.Linq.OrderedEnumerable`2[***]' to type 'System.Collections.Generic.IEnumerable`1[***]'
You're trying to convert a collection of DirectoryToken to a collection of Token. This is called a covariant conversion, and it's only supported in .Net 4.0 or later. If you can't upgrade, you can call .Cast<Token>() to create a new IEnumerable<T> instance (actually an iterator) that casts each object to the desired type. Under no circumstances do you need an explicit cast operation.

Categories : C#

Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.IConvertible'
It's exactly what the error says. You can't convert an SqlDataReader to a DateTime. If you want to query for just a single value, you should use: cmd2.ExecuteScalar(); If you are looking to retrieve a single value, I would suggest using TOP 1 in your query as well: SELECT TOP 1 DISTINCT loanUpdateDate Also note that ExecuteScalar() can return DbNull.Value if no value is found, so be sure to do a null check before trying to convert the value to anything.

Categories : C#

Unable to cast object of type 'System.Int32' to type 'System.Data.DataRowView'
Try to Direct Cast the value : (DirectCast(LbmCat.SelectedItem, DataRowView)("ID").ToString()) See it here. It may help

Categories : Vb.Net

Unable to cast object of type 'System.Int16' to type 'System.String'
This t.Field<string>("db_code").ToString() perhaps should be this: t.Field<short>("db_code").ToString() or equivalent t.Field<Int16>("db_code").ToString()

Categories : C#

Unable to cast object of type 'System.String[]' to type 'System.IConvertible'
Try this, weight is an array. Assuming you want to convert first element of array. string[] weight = txtProductOptn1.Text.Split(','); var Weight1 = Convert.ToInt32(weight[0]);

Categories : C#

generic type that extends interface, my variable returns null unless i cast it to a specific class
You need to be using a getter method. When you say rm.keyword, that's referring to a constant (zwave.keyword), which is the empty string. When you cast to Scene, the compiler sees that it's a field and looks it up instead. Generally, you should make fields like name and keyword private unless you have a specific reason not to and use getter and setter methods to manipulate them.

Categories : Java

how does Cpython implement its type Objects, i.e. type's type is always type?
The code that defines PyType_Type.ob_type = &PyType_Type involves a couple of indirections. It all starts in the function _Py_ReadyTypes() when it calls PyType_Ready(&PyType_Type). Before the function is called, the members tp_base and ob_type are both NULL. The function first sets type->tp_base to &PyBaseObject_Type (which is object in Python space) and then sets type->ob_type = PyBaseObject_Type.ob_type. The code uses Py_TYPE() which is just a macro for ob->ob_type. Since the type of object is type the code sets the type of type to type. Now you have: >>> type.__bases__ (<class 'object'>,) >>> type(object) <class 'type'> >>> type(type(object)) <class 'type'> The definition makes type an instance of object plus itself a

Categories : Python

Type 'MyClass' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type
One approach would be to override it: public new byte[] SomeByteArray { get; set; } and then you could ignore it with the IgnoreDataMember attribute.

Categories : C#

Entity Framework 5 table-per-type update, change sub type but keep same base type
I don't have a good answer, but I can think of four "solutions" that are really workarounds: Don't use DBMS-computed values for your primary keys (if you already use natural keys, it's fine). Use DBMS-computed surrogate keys. Follow something like the state pattern. Do some evil voodoo with the object state manager. Update: There seems to be a popular consensus that trying isn't even worth it; most people thus simply use stored procedures instead to work around the problem. Changing Inherited Types in Entity Framework Entity Framework: Inheritance, change object type Changing the type of an (Entity Framework) entity that is part of an inheritance hierarchy Changing the type of an entity that is part of an inheritance hierarchy Using natural keys First, remember that the objects tr

Categories : Entity Framework

LINQ To XML error: type of the expression in the select clause is incorrect. Type inference failed in the call to 'Select'
The problem is with your closing parenthesis - you've got it at the end of the ToList() call, when you meant to put it at the end of the object initializer. Also, you're not actually calling the method - you're just specifying a method group. Finally, you can let type inference work out the type argument for you: List<Data> dogs = (from q in doc.Descendants("dog") where (string)q.Attribute("name") == dogName select new Data { name = q.Attribute("name").Value, breed = q.Element("breed").Value, sex = q.Element("sex").Value }).ToList();

Categories : C#

Query on Junit @parameters method's return type and the test class constructor argument type
As you suggested the values are being casted. The casting is actually done by the Java reflection API, specifically: Constructor.newInstance(Object...). If you're curious, the above method is invoked by JUnit on line 186, here (JUnit v4.11 source).

Categories : Java

How to resolve the correct type from the container (static type vs runtime type)?
You'll need to do some sort of runtime resolution of the type. E.g. using the dynamic keyword: IBase a = new A(); Console.WriteLine(Resolve((dynamic)a)); A b = new A(); Console.WriteLine(Resolve((dynamic)b)); Or using reflection: int ResolveDynamic(IBase a) { MethodInfo method = typeof(IContainer).GetMethod("Resolve"); var handlerType = typeof(IHandler<>).MakeGenericType(a.GetType()); var enumerableType = typeof(IEnumerable<>).MakeGenericType(handlerType); MethodInfo generic = method.MakeGenericMethod(enumerableType); var result = (IEnumerable<object>)generic.Invoke(_container, null); return result.Count(); }

Categories : C#

is null in c# value type or reference type
Neither. null is the default value for reference types, but it does not have a type itself. Nullable value types are actually implemented as value types themselves - there are just compiler and library tricks to make them behave as expected when compared to null.

Categories : C#

Scala type mismatch: default.type (with underlying type A1 => B1)
Strange, as soon as I renamed default variable, everything compiled fine: scala> def composeHandlingFuture[T](fut: Future[T], x: T): Future[T] = | fut recover { case e: Exception => x } composeHandlingFuture: [T](fut: scala.concurrent.Future[T], x: T)scala.concurrent.Future[T]

Categories : Scala

How can I get type information about a type created using the type provider framework
At runtime, STable isn't a real .NET type - it's erased down to some other type (obj in this case) - this is just how (erasing) type providers work. If you absolutely need to get the type programmatically, then it's possible to do it using the raw type provider API, but this will be pretty ugly. To do this, get an instance of the ITypeProvider (just like the compiler does behind the scenes), and then navigate the resulting namespaces and types until you get the System.Type instance you're looking for.

Categories : F#

Hibernate RevEng Entity: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
Spring-Roo's Database Reverse Engineering tool works without problems, instead of using the Hibernate RevEng tool, I've successfully reverse engineered a db using Spring Roo: http://docs.spring.io/spring-roo/reference/html/base-dbre.html

Categories : Java

C#.NET Error: Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataSet'
It's because you're setting the DataSource to a DataTable: gvPartNumber.DataSource = dsgvPartNumber.Tables["partNumbers"]; not a DataSet. So, instead of this: DataSet dsgvPartNumberDelete = (DataSet)gvPartNumber.DataSource; do this: DataTable dsgvPartNumberDelete = (DataTable)gvPartNumber.DataSource; and then in the following lines you won't need accessors like .Tables[0]. It will already be a DataTable and thus more direct to access anyway. This modification would of course have to be replicated to all of your methods where you're trying to cast the DataSource as a DataSet.

Categories : C#

Method is returning int type, but I keep getting "this method must return a result of type int" error
What happens if control doesn't enter second level if? if (grid[i - 2][j] != 0) There is no return statement, isn't it? You need to have a return statement for all possible paths. How do I fix this? One possible way: Add return statement for first level if too. Example if (i - 1 >= 1){ if (grid[i - 2][j] != 0){ return xyTo1D(i - 1, j); } return -1; //OR whatever int you would like to return }

Categories : Java

Cannot Add class in Enum.Extensions namespace, because Enum type (System) is then inavailable
You will need to change the namespace of the Enum Library. Which is your first library project having Extensions. Enum is the Type name and you are using it as a namespace and hence there is ambiguity.

Categories : C#

Why the enum constants must be declared before any other variables and methods declaration in an enum type?
The ; indicates the end of the enum identnfiers list. Apparently you can have an empty enum list, but you must have one. See 8.9.1 of the Java Language Specification: 8.9.1 Enum Constants The body of an enum type may contain enum constants

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.