| | |
sql query problem with MS Access and C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2006
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by msaqib
sorry, actually u didnt understand my problem. I jsut wanted to know that
if i run "select * from book where name like '*x*' OR description like '*x*';" from the MS Access then it returns some records containing X somewhere in the text.
But if i run it throught C# code and execute the query it returns no records.
why?
replace your query with the following
"select * from book where name like '%x%' OR description like '%x%';"
•
•
Join Date: Jun 2007
Posts: 1
Reputation:
Solved Threads: 0
Hello.
I ran into the same problem today. Fortunatelly for me
, I found the solution.
My old code:
I tried with both % and *. Nothing worked. I searched google, but didn't found answear. Then I tried:
Adding % sepparately, as a char, does the trick. (depending on the access file version, you may need to use * instead of % - the former works on Access 2003 file format).
I hope this helps.
P.S. Sorry for the bad english, it is not my native language.
I ran into the same problem today. Fortunatelly for me
, I found the solution.My old code:
C# Syntax (Toggle Plain Text)
filter+= "(invoice.serie LIKE '%" + txtInvoiceSerie.Text + "%')";
C# Syntax (Toggle Plain Text)
filtru += "(invoice.serie LIKE '" + '%' + txtInvoiceSerie.Text + '%'+"')";
I hope this helps.
P.S. Sorry for the bad english, it is not my native language.
•
•
Join Date: Sep 2007
Posts: 1
Reputation:
Solved Threads: 0
Thank You All
I Had The same problem then when i replaced * with % every thing became right
Here is Some Code :
SQLStatement = SQLStatement + " and StudentName like '%" + textBox26.Text + "%'";
OleDbCommand command = new OleDbCommand(SQLStatement, gConnection);
gDataAdapter.SelectCommand = command;
gDataTable.Clear();
OleDbCommandBuilder gCommandBuilder = new OleDbCommandBuilder(gDataAdapter);
gDataAdapter.Fill(gDataTable);
dataGridView1.DataSource = gDataTable;
Sorry for the bad english, it is not my native language.
my language is Arabic.
I Like Arabic verymuch.
I Had The same problem then when i replaced * with % every thing became right
Here is Some Code :
SQLStatement = SQLStatement + " and StudentName like '%" + textBox26.Text + "%'";
OleDbCommand command = new OleDbCommand(SQLStatement, gConnection);
gDataAdapter.SelectCommand = command;
gDataTable.Clear();
OleDbCommandBuilder gCommandBuilder = new OleDbCommandBuilder(gDataAdapter);
gDataAdapter.Fill(gDataTable);
dataGridView1.DataSource = gDataTable;
Sorry for the bad english, it is not my native language.
my language is Arabic.
I Like Arabic verymuch.
Last edited by abd_alrahman111; Sep 30th, 2007 at 6:55 am.
•
•
Join Date: Oct 2007
Posts: 1
Reputation:
Solved Threads: 0
Hello.
I'm having a similar problem. My LIKE sql statements are not retrieving the correct records. The difference, in my case, is that it is returning records, only incorrect records. Let's say the query should return 3 records. Instead of returning 3 different records, it returns the first record 3 times.
If I use *'s, I get no records, which makes be believe the correct wild card card is %. And it's using % that is causing the error described in the first paragraph.
I have already tried to append % surrounded by single quote, double quotes, in the same line as the rest of the string, and in a separate line. Every time I get the same result.
Does anybody have a clue? Any help will be much appreciated.
Thanks a lot in advance
I'm having a similar problem. My LIKE sql statements are not retrieving the correct records. The difference, in my case, is that it is returning records, only incorrect records. Let's say the query should return 3 records. Instead of returning 3 different records, it returns the first record 3 times.
If I use *'s, I get no records, which makes be believe the correct wild card card is %. And it's using % that is causing the error described in the first paragraph.
I have already tried to append % surrounded by single quote, double quotes, in the same line as the rest of the string, and in a separate line. Every time I get the same result.
Does anybody have a clue? Any help will be much appreciated.
Thanks a lot in advance
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
sorry, actually u didnt understand my problem. I jsut wanted to know that
if i run "select * from book where name like '*x*' OR description like '*x*';" from the MS Access then it returns some records containing X somewhere in the text.
But if i run it throught C# code and execute the query it returns no records.
why?
![]() |
Similar Threads
- SQL query problem with WHERE clause (ASP)
- Please help me out with MySQL query (MySQL)
- query problem (MySQL)
Other Threads in the C# Forum
- Previous Thread: vertical line
- Next Thread: Sending data to e-mail
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format formatting forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot marshalbyrefobject math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





