I am trying to pull out data from an Access mdb via the Like()
operator. The code works fine for specific values ie 3, 4 but fails for
the '*' value.

TIA for any hints. Mark

Code excerpt: (ddnEmp.SelectedValue is a dropdown box, with values: 0,
1, 2 etc.)

Dim mstrConn As String =
ConfigurationManager.ConnectionStrings("DbConn").ConnectionString
Dim mobjConnection As New OleDbConnection(mstrConn)

Dim strFrom As String = ddnEmp.SelectedValue
Dim strSQL As String = "SELECT qryActByDay.*, * FROM qryActByDay WHERE
qryActByDay.ActFrom Like(@From);"

Dim objCommand As New OleDbCommand(strSQL, mobjConnection)

Dim prm As New OleDbParameter()
With prm
.ParameterName = "@From"
'If 0 show all data
If strFrom <> "0" Then .Value = strFrom Else .Value = "'*'"
End With
objCommand.Parameters.Add(prm)

Re: Like('*') won't work in Access qry by Edwin

Edwin
Wed Jul 19 14:55:56 CDT 2006

Try percentage %


<msch-prv@bluewin.ch> schreef in bericht
news:1153338340.009864.106970@h48g2000cwc.googlegroups.com...
>I am trying to pull out data from an Access mdb via the Like()
> operator. The code works fine for specific values ie 3, 4 but fails for
> the '*' value.
>
> TIA for any hints. Mark
>
> Code excerpt: (ddnEmp.SelectedValue is a dropdown box, with values: 0,
> 1, 2 etc.)
>
> Dim mstrConn As String =
> ConfigurationManager.ConnectionStrings("DbConn").ConnectionString
> Dim mobjConnection As New OleDbConnection(mstrConn)
>
> Dim strFrom As String = ddnEmp.SelectedValue
> Dim strSQL As String = "SELECT qryActByDay.*, * FROM qryActByDay WHERE
> qryActByDay.ActFrom Like(@From);"
>
> Dim objCommand As New OleDbCommand(strSQL, mobjConnection)
>
> Dim prm As New OleDbParameter()
> With prm
> .ParameterName = "@From"
> 'If 0 show all data
> If strFrom <> "0" Then .Value = strFrom Else .Value = "'*'"
> End With
> objCommand.Parameters.Add(prm)
>



Re: Like('*') won't work in Access qry by msch-prv

msch-prv
Wed Jul 19 15:04:40 CDT 2006

Thanks for the feedback Edwin.

I tried with '%' , % ie Like(%), Like('%') to no avail. Mark


Re: Like('*') won't work in Access qry by Edwin

Edwin
Wed Jul 19 15:09:44 CDT 2006

Try access first, i don't recognize the () stuff.
If access requires * then simply swap % for dotnet.



<msch-prv@bluewin.ch> schreef in bericht
news:1153339480.889553.23660@p79g2000cwp.googlegroups.com...
> Thanks for the feedback Edwin.
>
> I tried with '%' , % ie Like(%), Like('%') to no avail. Mark
>



Re: Like('*') won't work in Access qry by msch-prv

msch-prv
Wed Jul 19 15:22:30 CDT 2006

Nope, I removed the brackets and tried with '%', ' %*%' By the way,
Access doesn't mind about either Like('*') or Like '*'.


Re: Like('*') won't work in Access qry by msch-prv

msch-prv
Wed Jul 19 15:40:00 CDT 2006

Edwin, my apologies. You were right! Somewhere in my code, input
ddnEmp.SelectedValue was tied to "'*'", which caused the code to fail.

The following does it:
If strFrom <> "0" Then .Value = strFrom Else .Value = "%"

Thanks again, Mark