Re: Parameters Question
- From: "Kerry Moorman" <KerryMoorman@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 13 May 2005 10:41:09 -0700
Scott,
But as I said in my post, I have never been able to get named parameters to
work in OLEDB for SQL Server. In my SQL statements I cannot use, for example
"@ID". Instead I must use "?" as a placeholder. And my parameters must be in
the same order as the "?" placeholders. Again, this is not the case for
Access.
Also as I said in my post, the reason I sometimes use OLEDB for both Access
and SQL Server is so I can upsize the Access database to SQL Server and use
the same ADO.Net code (yes I realize that SQLClient provides better
performance).
Do you have an example of using named parameters with OLEDB for both Access
and SQL Server? Perhaps you have always used the SQLClient for SQL Server
databases and you never noticed how the OLEDB stuff works differently with
SQL Server than with Access?
Kerry
"Scott M." wrote:
> But think about this for a second...If named parameters will work in OLEDB
> for Access (in any sequence) and they will also work in OLEDB for SQL (in
> the correct sequence only), then why not just used named parameters in the
> correct sequence all the time and both would be happy. In addition,
> (realistically speaking) why would you be using OLEDB with SQL rather than
> the SQLClient namespace?
>
>
> "Kerry Moorman" <KerryMoorman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:75521369-4646-4914-9468-A93E6AD60678@xxxxxxxxxxxxxxxx
> > Scott,
> >
> > In my experience, the OLEDB provider for Access lets you use named
> > parameters or the question mark character (and maybe additional options).
> >
> > The OLEDB provider for SQL Server (Provider=SQLOLEDB) will not allow named
> > parameters. It will work with question mark placeholders. The parameters
> > then
> > must be in the order of the question marks.
> >
> > I would love to see some code that uses OLEDB to work with both Access and
> > SQL Server databases where you can use parameter names in any order for
> > both
> > Access and SQL Server. Since I have never been able to get this to work, I
> > always use question marks for both databases (when using OLEDB) so the
> > code
> > will work with just connection string changes between the 2 databases.
> >
> > Kerry Moorman
> >
> >
> > "Scott M." wrote:
> >
> >> In ADO.NET, you don't use the question mark to indicate a parameter
> >> value,
> >> you use @paramaterName as in:
> >>
> >> "SELECT * FROM tblUsers WHERE User=@user"
> >>
> >> Check out this for more info:
> >>
> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbparameterclasstopic.asp
> >>
> >>
> >>
> >>
> >> "ltt19" <ltt19@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:1A0A7F63-C0DD-45BF-BB7C-11675BB479CC@xxxxxxxxxxxxxxxx
> >> > Hi,
> >> >
> >> > I'm new to ADO.net, even new to Databases access, and I have a
> >> > CommandText
> >> > that is useful to all of my tables, however I can not find the
> >> > approppiate
> >> > use of paramnter to do this. Like:
> >> >
> >> > "SELECT * FROM ?"
> >> >
> >> > I'm using an Acess database and the OLEDB.
> >> >
> >> > Another Question, How can I use paramter to Select Fields that can be
> >> > chosen by the user? Like a "SELECT ? ? FROM Music" but I don't know
> >> > wich
> >> > are
> >> > these "?" and how many will have.
> >> >
> >> > Hope that I was clear.
> >> >
> >> > Any help would be very useful.
> >> > Thanks in advance.
> >> >
> >>
> >>
> >>
>
>
>
.
- Follow-Ups:
- Re: Parameters Question
- From: Scott M.
- Re: Parameters Question
- From: gabe garza
- Re: Parameters Question
- References:
- Parameters Question
- From: ltt19
- Re: Parameters Question
- From: Scott M.
- Re: Parameters Question
- From: Kerry Moorman
- Re: Parameters Question
- From: Scott M.
- Parameters Question
- Prev by Date: Re: MSDE Backup
- Next by Date: Re: Parameters Question
- Previous by thread: Re: Parameters Question
- Next by thread: Re: Parameters Question
- Index(es):
Relevant Pages
|
Loading