vbturbo
asked on
casting /filtering problem
Hi
Im trying to cast a dataview column to string
Property Expression can not be used , because there is a cirkular reference in the expression
I have the problem filtering a column which is a type of integer use the like operator when passing a txtbox input e.g = 4
how can i address this problem?
vbturbo
Im trying to cast a dataview column to string
Property Expression can not be used , because there is a cirkular reference in the expression
I have the problem filtering a column which is a type of integer use the like operator when passing a txtbox input e.g = 4
how can i address this problem?
vbturbo
parentView.Table.Columns("import_policeid").Expression = "Convert('import_policeid',System.String)"
With parentView
.RowFilter = "import_policeid Like '%" & txtsearch.Text & "%' Or xml_kunde_navn Like '%" & txtsearch.Text & "%' Or import_kundenr Like '%" & txtsearch.Text & "%' Or xml_kunde_adresse1 Like '%" & txtsearch.Text & "%' Or import_id Like '%" & txtsearch.Text & "%'"
.RowStateFilter = DataViewRowState.CurrentRows
End With
.RowFilter = "import_policeid Like '%" & txtsearch.Text & "%' Or xml_kunde_navn Like '%" & txtsearch.Text & "%' Or import_kundenr Like '%" & txtsearch.Text & "%' Or xml_kunde_adresse1 Like '%" & txtsearch.Text & "%' Or import_id=" & txtsearch.Text & ""
.RowStateFilter = DataViewRowState.CurrentRo ws
End With
.RowStateFilter = DataViewRowState.CurrentRo
End With
ASKER
throws this exception
There is missing an operand after operator 'Mod'.
I need also to be able to use the like operator on import_id =" & txtsearch.Text & "%" instead of the equal operator
thanks
There is missing an operand after operator 'Mod'.
I need also to be able to use the like operator on import_id =" & txtsearch.Text & "%" instead of the equal operator
thanks
ASKER
your second suggestion throws
Column [s] was not found.
Column [s] was not found.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well i have redefined my structure a bit and it works ,but.....
With parentView
If bool = False Then
.RowFilter = "" & var & " Like '%" & txtsearch.Text & "%'"
Else
' here it shows only the exact match........How do i apply the like operator ????????
.RowFilter = "" & var & " = " & txtsearch.Text & ""
End If
.RowStateFilter = DataViewRowState.CurrentRo ws
End With
thanks
With parentView
If bool = False Then
.RowFilter = "" & var & " Like '%" & txtsearch.Text & "%'"
Else
' here it shows only the exact match........How do i apply the like operator ????????
.RowFilter = "" & var & " = " & txtsearch.Text & ""
End If
.RowStateFilter = DataViewRowState.CurrentRo
End With
thanks
you can't apply like to int
ASKER
but then how can i cast the "import_policeid" column to string ?
parentView.Table.Columns(" import_pol iceid").Ex pression = "Convert('import_policeid' ,System.St ring)"
throws
Property Expression can not be used , because there is a cirkular reference in the expression
parentView.Table.Columns("
throws
Property Expression can not be used , because there is a cirkular reference in the expression
why you need like for the int ?
ASKER
to filter out long invoice numbers.(15-18 digits)
Im just looking for a solution to cast a column to string.
And of course create a overhead by adding a column to the table ,assign the values from the int column
then remove the int column .........ect
that i would like to avoid.
Do you know how to cast/convert a column to string ?
Im just looking for a solution to cast a column to string.
And of course create a overhead by adding a column to the table ,assign the values from the int column
then remove the int column .........ect
that i would like to avoid.
Do you know how to cast/convert a column to string ?
ASKER
sorry correction:
to filter out long invoice numbers.(15-18 digits)
Im just looking for a solution to cast a column to string.
Of course i could create a overhead by adding a column to the table ,assign the values from the int column
then remove the int column .........ect
that i would like to avoid.
Do you know how to cast/convert a column to string ?
to filter out long invoice numbers.(15-18 digits)
Im just looking for a solution to cast a column to string.
Of course i could create a overhead by adding a column to the table ,assign the values from the int column
then remove the int column .........ect
that i would like to avoid.
Do you know how to cast/convert a column to string ?
ASKER
at the middle of this page it shows how to convert a datatable column
but where am i dropping the ball ?
https://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.71).aspx
The following functions are also supported:
CONVERT
Description Converts given expression to a specified .NET Framework Type.
Syntax Convert(expression, type)
Arguments expression-- The expression to convert.
type-- The .NET Framework type to which the value will be converted.
Example: myDataColumn.Expression="C onvert(tot al, 'System.Int32')"
but where am i dropping the ball ?
https://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.71).aspx
The following functions are also supported:
CONVERT
Description Converts given expression to a specified .NET Framework Type.
Syntax Convert(expression, type)
Arguments expression-- The expression to convert.
type-- The .NET Framework type to which the value will be converted.
Example: myDataColumn.Expression="C
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Roger
Sorry for my late responce, just came home from work.
Thanks for an "as always" competent responce and elaboration.
Glad that you still are around, long time no see -;)
I really miss some of your comments as you seem absent now a days.
Thinking deeper in applying the convert() function in the rowfilter.
Should be possible in the same way as in a SQL select against a datasource where you can cast and convert
Ill do some testing in this regard.
If anything else pops into your mind please drop in with a comment.
Jens
Sorry for my late responce, just came home from work.
Thanks for an "as always" competent responce and elaboration.
Glad that you still are around, long time no see -;)
I really miss some of your comments as you seem absent now a days.
Thinking deeper in applying the convert() function in the rowfilter.
Should be possible in the same way as in a SQL select against a datasource where you can cast and convert
Ill do some testing in this regard.
If anything else pops into your mind please drop in with a comment.
Jens
ASKER
Roger
I think this should the trick
parentView.RowFilter = "Convert(import_policeid, 'System.String') Like '%" & txtsearch.Text & "%'"
ill test it tomorrow and let you know
Jens
I think this should the trick
parentView.RowFilter = "Convert(import_policeid, 'System.String') Like '%" & txtsearch.Text & "%'"
ill test it tomorrow and let you know
Jens
Jens
I've been, and still am, rather busy on other things. So although I keep an eye on EE when I can, I'm not contributing so much. In particular, I try to resist posting where it looks like the thread might get protracted. But I know that you and I are "on the same wavelength" and that you'd get the point I was trying to make without me having to put it in half a dozen different ways. Hence my comment on this.
It looks like it should work. I'll be interested to hear if it does.
Roger
I've been, and still am, rather busy on other things. So although I keep an eye on EE when I can, I'm not contributing so much. In particular, I try to resist posting where it looks like the thread might get protracted. But I know that you and I are "on the same wavelength" and that you'd get the point I was trying to make without me having to put it in half a dozen different ways. Hence my comment on this.
It looks like it should work. I'll be interested to hear if it does.
Roger
ASKER
Roger
It works like a charm.
Jens
It works like a charm.
Jens
.RowStateFilter = DataViewRowState.CurrentRo
End With