W
William \(Bill\) Vaughn
I stand corrected. It turns out that while you don't need "?", the "@"
prefix on the "named" parameter works fine--but the names are not used for
anything but placeholders. The marker strings simply need to be unique to be
differentiated. This query returns 3 rows. If you reverse the order of how
the parameters are added to the Parameters collection, it still runs, but
returns 0 rows as the parameters don't match up with the SQL in the query.
Try
Dim cn As OleDbConnection
cn = OleDbConnection1
cn.Open()
Dim da As New OleDbDataAdapter("SELECT * " _
& " FROM Customers WHERE Country = @ AND ContactTitle = @1", cn)
da.SelectCommand.Parameters.Add("@Cntry", "Mexico")
da.SelectCommand.Parameters.Add("@Title", "Owner")
Dim ds As New DataSet
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Sorry for the confusion. I guess I'm spending too much time with SQL Server
to help much here in JET land.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
prefix on the "named" parameter works fine--but the names are not used for
anything but placeholders. The marker strings simply need to be unique to be
differentiated. This query returns 3 rows. If you reverse the order of how
the parameters are added to the Parameters collection, it still runs, but
returns 0 rows as the parameters don't match up with the SQL in the query.
Try
Dim cn As OleDbConnection
cn = OleDbConnection1
cn.Open()
Dim da As New OleDbDataAdapter("SELECT * " _
& " FROM Customers WHERE Country = @ AND ContactTitle = @1", cn)
da.SelectCommand.Parameters.Add("@Cntry", "Mexico")
da.SelectCommand.Parameters.Add("@Title", "Owner")
Dim ds As New DataSet
da.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Sorry for the confusion. I guess I'm spending too much time with SQL Server
to help much here in JET land.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________