Problem with Access SQL
-
In a test I'm making I type this
oledbDataAdapter.SelectCommand.CommandText = "SELECT * FROM tbl_clientes;" oledbDataAdapter.Fill(Dataset) Me.DataGridBuscar.DataSource = Dataset
Then I change the code tooledbDataAdapter.SelectCommand.CommandText = "SELECT * FROM tbl_clientes WHERE nombre LIKE '*j*';" oledbDataAdapter.Fill(Dataset) Me.DataGridBuscar.DataSource = Dataset
And nothing is selected!!! If I copy and paste the SQL in the access editor, it returns a few records that begins with "j" (what I want!) Why this not runs in VBNET? Thanks. -
In a test I'm making I type this
oledbDataAdapter.SelectCommand.CommandText = "SELECT * FROM tbl_clientes;" oledbDataAdapter.Fill(Dataset) Me.DataGridBuscar.DataSource = Dataset
Then I change the code tooledbDataAdapter.SelectCommand.CommandText = "SELECT * FROM tbl_clientes WHERE nombre LIKE '*j*';" oledbDataAdapter.Fill(Dataset) Me.DataGridBuscar.DataSource = Dataset
And nothing is selected!!! If I copy and paste the SQL in the access editor, it returns a few records that begins with "j" (what I want!) Why this not runs in VBNET? Thanks.Two things. 1) You say that you want to find records that "START" with J. Do not use a wild card in front of the letter else you will match records that have a j anywhere within the text. 2) Try using % character instead of * character as the wildcard indicator. I have had some luck doing this.
-
Two things. 1) You say that you want to find records that "START" with J. Do not use a wild card in front of the letter else you will match records that have a j anywhere within the text. 2) Try using % character instead of * character as the wildcard indicator. I have had some luck doing this.
It works like you say... but why in access my query returns values and in VB not? Thanks a lot!
-
It works like you say... but why in access my query returns values and in VB not? Thanks a lot!
Not sure of the real explanation, but it works. Access does not reconize % as a wildcard. But when passed a sql statement, it works. Crazy Microsoft products...... -- modified at 14:32 Thursday 8th September, 2005
-
Not sure of the real explanation, but it works. Access does not reconize % as a wildcard. But when passed a sql statement, it works. Crazy Microsoft products...... -- modified at 14:32 Thursday 8th September, 2005
Yup, that happened to me too with the distinct command. Just make sure you check the syntax if it's compatible with the access. ;)