I am using an access database and executing the following piece of code:

IDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\test.mdb;Persist Security Info=False");
try{
con.Open();
IDbCommand cmd = con.CreateCommand();
cmd.CommandText = "SELECT * FROM MyTable WHERE Tag Like 'A*'";
IDataReader reader = cmd.ExecuteReader();
if(!reader.Read())
MessageBox.Show("Fail");
else
reader.Close();
}

The fail message box is always shown, what means that no data was found. My
column "Tag" has several registers with the value "AlrDigCmd[1]". If I try
to use Tag = 'AlrDigCmd[1]', it works. I need to use wildcards, does anyone
know what am I doing wrong? Also, is the "Like" predicate available to any
provider or it may not be depending on the implementation?

Another issue that I have is that I would like a case insensitive query.
What would be the best way to do it?

I would really appreciate any help.

Lourenço.

Re: Like problem and question by Andy

Andy
Thu May 13 19:47:09 CDT 2004

Try this

SELECT * FROM MyTable WHERE Tag Like 'A%'

That query will be case insensitive.

"Lourenço Teodoro" <lourenco_xxi@hotmail.com> wrote in message
news:ujOCShSOEHA.1276@TK2MSFTNGP11.phx.gbl...
> I am using an access database and executing the following piece of code:
>
> IDbConnection con = new
> OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:\\test.mdb;Persist Security Info=False");
> try{
> con.Open();
> IDbCommand cmd = con.CreateCommand();
> cmd.CommandText = "SELECT * FROM MyTable WHERE Tag Like 'A*'";
> IDataReader reader = cmd.ExecuteReader();
> if(!reader.Read())
> MessageBox.Show("Fail");
> else
> reader.Close();
> }
>
> The fail message box is always shown, what means that no data was found.
My
> column "Tag" has several registers with the value "AlrDigCmd[1]". If I try
> to use Tag = 'AlrDigCmd[1]', it works. I need to use wildcards, does
anyone
> know what am I doing wrong? Also, is the "Like" predicate available to any
> provider or it may not be depending on the implementation?
>
> Another issue that I have is that I would like a case insensitive query.
> What would be the best way to do it?
>
> I would really appreciate any help.
>
> Lourenço.
>
>



Re: Like problem and question by Lourenço

Lourenço
Fri May 14 09:14:24 CDT 2004

I tried, but it is still not returning any register.

Lourenço.

"Andy Gaskell" <pubb AT hotmail DOT com> wrote in message
news:O5N74zUOEHA.3964@TK2MSFTNGP10.phx.gbl...
> Try this
>
> SELECT * FROM MyTable WHERE Tag Like 'A%'
>
> That query will be case insensitive.
>
> "Lourenço Teodoro" <lourenco_xxi@hotmail.com> wrote in message
> news:ujOCShSOEHA.1276@TK2MSFTNGP11.phx.gbl...
> > I am using an access database and executing the following piece of code:
> >
> > IDbConnection con = new
> > OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=C:\\test.mdb;Persist Security Info=False");
> > try{
> > con.Open();
> > IDbCommand cmd = con.CreateCommand();
> > cmd.CommandText = "SELECT * FROM MyTable WHERE Tag Like 'A*'";
> > IDataReader reader = cmd.ExecuteReader();
> > if(!reader.Read())
> > MessageBox.Show("Fail");
> > else
> > reader.Close();
> > }
> >
> > The fail message box is always shown, what means that no data was found.
> My
> > column "Tag" has several registers with the value "AlrDigCmd[1]". If I
try
> > to use Tag = 'AlrDigCmd[1]', it works. I need to use wildcards, does
> anyone
> > know what am I doing wrong? Also, is the "Like" predicate available to
any
> > provider or it may not be depending on the implementation?
> >
> > Another issue that I have is that I would like a case insensitive query.
> > What would be the best way to do it?
> >
> > I would really appreciate any help.
> >
> > Lourenço.
> >
> >
>
>