I'm getting this error when I issue this:
DataContext.DBProjectEntities.Projects.Where(xWhere, parameterList.ToArray)
The command parameter syntax '#0' is not valid. Near line 6, column 37.
xWhere is a string containing value "(ProjectStatuses.Any(DepartmentID = #0))"
parameterList is Dim parameterList As New List(Of ObjectParameter)
It contains one element with value 1 of type Int32 which corresponds to the type of DepartmentID.
I got it. I was using the dunamic.vb from an external assembly. In my code I had imports statement for that assembly, but I also needed the imports for system.linq.dynamic
Related
I am trying to iterate through dictionary but encounter the error "Object required". The related code is given below.
First, I create a dictionary.
Dim customers
Set customers = CreateObject("Scripting.Dictionary")
I also define class of "cCustomer", then use the dictionary like this.
Set customer = New cCustomer
customer.Init location, first, last
customers.Add location, customer
Then I use "For Each" to iterate.
Dim cc
For Each cc in customers.items
...
Next
This is OK. But I really want to declare "cc" with type.
Dim cc As cCustomer
But if I do this, VB runtime complains "Object required" at the line of "For Each". I think it is somehow related to the missing of type declaration when creating the dictionary? I am still new to VB. Thanks for the help.
MORE: why this is not duplicate...
I have tried the solution suggested by the link, namely, (a) using Dictionary instead of "Scripting.Dictionary", and (b) "Dim cc As Variant". It works as before but if I feed "cc" into a function whose argument has specific type it still fails.
Public Function foo(customer As cCustomer) As String
...
End Function
Dim cc As Variant
For Each cc in customers.items
foo(cc)
Next
The error is "ByRef argument type mismatch".
That's the reason I really need to declare "cc" as "cCustomer", but it has error of "Object required".
Dim cc As cCustomer
For Each cc In customers.items
...
Per comments
tried "Dim cc As Object", doesn't work ("Object required").
tried "remove Dim cc", doesn't work either ("ByRef argument type mismatch").
I could do "ByVal" in the function definition or use another variable, but that would involve extra copy. Something like type casting might help...
It's a bit of a cludge and there may be better ways of doing it, but how about this:
dim loc as variant
dim cc as cCustomer
for each loc in Customers
set cc = Customers(loc)
foo(cc)
next loc
It may even be possible to do foo (Customers(loc)), but I suspect you will get the type mismatch error again. I don't think you can pass an object with byval
I'm getting this error when trying to build the app:
<unknown>:0: error: cannot assign value of type 'Array<_>' to type 'Array'
but Xcode is not indicating a specific line or class for the failure.
If I could understand the difference between
Array<_>
&
Array
it may help me locate the issue.
When you app is crashing, than you can turn on All Exceptions for Debug breakpoint. This should stop on the line where the crash appears.
You find this in Xcode on the Left Panel-> BreakPoint Navigator.
Than press the + in the bottome left corner and Add Exception Breakpoint.
It looks like that you overwrite an array with an array that has a specific value definition. Good Luck :)
A generic argument clause is enclosed in angle brackets ( < > )
< generic argument list >
You can replace a type parameter with a type argument that is itself a specialized version of a generic type.For example, you can replace the type parameter T in Array < T > with a specialized version of an array, Array< Int > , Array< String >, to form an array whose elements are themselves array of integers / Strings
Regarding xour code Snippet the fix is:
u should define it with the right value ... userTweetsArray : [String] = String . or remove the : [String] because setting the value defines already the object and type :)
I don't like answering my own questions but for the sake of closure
I had this line of code
var userTweetsArray : Array = [String]()
I never actually used it. Once I removed that line the error had gone.
The error was caused by assigning an array of a type in this case String to an Array of no type.
So difference is Array<_> is an array of a type and Array is not.
I have the below code which uses a method. When I try to assign the Field Symbol value [Type ANY] to the return parameter RO_TAB [Type Ref to Data], I am getting an error message OBJECTS_MOVE_NOT SUPPORTED [Conversion of type "l" to type "g" not supported.].
The issue is happening after a BW system upgrade along with which we also moved to ABAP objects. The code executes perfectly in the older version of ABAP.
The dump occurs in the below line:
RO_TAB = <lf_storage>.
I have no idea why.
method GET_LU_STORAGE_FOR_ODS.
* IMPORTS
* IF_ODS TYPE RSODSTECH
* IF_ODS_TABLE_TYPE TYPE ZODS_TAB_TYPE
* RETURNS
* RO_TAB TYPE REF TO DATA
FIELD-SYMBOLS:
<lf_storage> TYPE ANY.
DATA:
lf_index TYPE SY-TABIX,
lf_sindex TYPE STRING,
lf_name TYPE STRING.
lf_index = GET_LU_STORAGE_INDEX(
IF_ODS = IF_ODS
IF_ODS_TABLE_TYPE = IF_ODS_TABLE_TYPE ).
lf_sindex = lf_index.
CONCATENATE
'MO_LU_DATA_'
lf_sindex
INTO lf_name.
ASSIGN lf_name TO <lf_storage>.
RO_TAB = <lf_storage>.
endmethod.
You need to create a data object first, using the CREATE DATA statement. Then you can ASSIGN a field symbol to work with the dynamically created data object. There's an example in the online manual. A field symbol is not a reference, it simply places the variable assigned to it in its position. You're effectively trying to move a string (which is what lf_name is) to a reference variable, and that won't work.
You cannot assign a variable of type STRING to a variable of type REF TO DATA.
The following code snippet shows how it should be done.
DATA: lf_name TYPE string.
DATA: lo_tab TYPE REF TO DATA.
FIELD-SYMBOLS: <lf_name> TYPE string.
lf_name = 'test'.
GET REFERENCE OF lf_name INTO lo_tab.
*lf_name = lo_tab. "this is not allowed
ASSIGN lo_tab->* TO <lf_name>.
So in your case it would be sufficient to define a field symbol.
FIELD-SYMBOLS: <lf_name> TYPE STRING.
then assign the contents referenced by RO_TAB to this field symbol.
ASSIGN ro_tab->* TO <lf_name>.
and finally do the concatenation.
CONCATENATE
'MO_LU_DATA_'
lf_index
INTO <lf_name>.
That's all! No further assignments should be required.
How about just this?
lf_sindex = lf_index.
CONCATENATE
'MO_LU_DATA_'
lf_sindex
INTO RO_TAB.
I'm trying to do the following update using XPages Extension Library.
#{javascript:var mydata = {
product: getComponent("inputProduct").getValue()
};
var params = [1, 2];,
#JdbcUpdate("mssql","table_name",mydata,"order_no=? AND order_line_no=?",params)};
I get the error:
Error while executing JavaScript action expression
Script interpreter error, line=6, col=1: Error while executing function '#JdbcUpdate'
Invalid column name 'PRODUCT'.
The problem is that XPages when it converts the JSON it puts product to PRODUCT.
Can you set the extension library to respect the case of the JSON and not convert to Uppercase? Or can anyone point to where this setting could be set if not the extension library?
Thanks
The problem is com.ibm.xsp.extlib.util.JdbcUtil.appendColumnName()
public static void appendColumnName(StringBuilder b, String colName) {
colName = colName.toUpperCase();
b.append(colName);
}
This just needs changing to not upper case the variable.
There may be other methods that need changing if other variables are getting upper cased.
I'm getting this exception in this code:
Dim TSV As TimeScaleValues
TSV = ActiveProject.Task(ntask).Resources(nresource).TimeScaleData(nStartDate , nEndDate, PjResourceTimescaledData.pjResourceTimescaledActualWork, PjTimescaleUnit.pjTimescaleDays, 1)
TSV.item(1).Add( nMinutes , 1 ) ' nMinutes is the value of time in minutes. The error occours in this line !!!!
When I execute the last line I get this exception
Invalid value for argument.
Error code -2146827187
{Microsoft.Office.Interop.MSProject.TimeScaleValue Add(System.Object, System.Object)}
The estrange thing is that I got this example right from this microsoft reference page.
What I'm trying to do is add a time to time scale on project.
I solved the problem.
I was setting the value in the wrong place.
Seems confuse, but I was trying to get the time scale value from resource, but the right place to set the values is on assignments.
I was doing this..
TSV = ActiveProject.Task(ntask).Resources(nresource).TimeScaleData...
The right code is like:
TSV = ActiveProject.Assignments.TimeScaleData..
For each resource in the task is created one assingment, so teh final code is like:
For Each assignment As Assignment In Task.Assigments
if assignment.Resource.WindowsUserAccount = <desiredAccount> then
tsv = assingment.TimeScaleData..
end if
Next