When a Data Connection is established using
Microsoft SQL Server Database File (SqlClient) as a data source
the following code works perfectly
SELECT *
FROM ProdMaster
WHERE (PRODMASTER.DESCRIPTION LIKE '%' + @DESCRIPTION + '%')
The ToolStrip on the form opens an input box so you can type in a choice of DESCRIPTION and when the button is clicked the dataset returns only those values
that meet the criteria input
BUT
If you use a Data Connection established using
Microsoft Access Database File (OLE DB)
when you attempt to establish the querry above you get the following error
Error in WHERE clause near '@'.
Unable to parse query text.
Can anyone help me here

Problem creating a querry with an embeded variable when using access datafile as connection source
FONTANA Guillaume
gen
I don't know. . .
Everything I have seen says OleDb does not support named parameters and you must use in your query text.
Join
Access OLEDB provider supports named parameters
In the Query text I know you can name them after you specify the query text.
How do you name them in the command
DevGuy_
I will double check to make sure, but AFAIK OLEDB parameters are resolved by their ordinal position in the Command (at least in ADO.NET). You can use names but it would purely be to make your code more readable. The names are essentially ignored.
LDesmons
SamD
SQL Server OLEDB Provider requires something like: SELECT * WHERE SomeColumn =
Jet OLEDB Provider can take either, and I've used each at various times when interacting with Access.
IraD
note: code may contain errors, as I am just spitting it out
dim connStr as string = [your connection string]
dim sql as string = "SELECT * FROM PRODMASTER " &_
"WHERE DESCRIPTION LIKE "
Dim dt as new DataTable
Using con as New OleDbConnection(connstr)
Using da as new OleDbDataAdapter(sql, con)
cmd.Parameters.Add("description", string.Format("%{0}%", DescriptionTextBox.Text))
da.Fill(dt)
End Using
End Using
Trevor L.
Simn
Blair thank you for the input
forgive my ignorance but where do I place the code you have provided me
Crumbs
note: code may contain errors, as I am just spitting it out
dim connStr as string = [your connection string]
dim sql as string = "SELECT * FROM PRODMASTER " &_
"WHERE DESCRIPTION LIKE "
Dim dt as new DataTable
protected override sub OnLoad(ByVal e as EventArgs)
Using con as New OleDbConnection(connstr)
Using da as new OleDbDataAdapter(sql, con)
cmd.Parameters.Add("description", string.Format("%{0}%", DescriptionTextBox.Text))
da.Fill(dt)
End Using
End Using
MyBase.OnLoad(e)
end sub