🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database.dotnet
Article #605

Re: Passing Parameters using OleDb

#605
From: Viatcheslav V. Vassiliev
Date: Thu, 04 Nov 2004 10:36
84 lines
3797 bytes
Analogic code works for MS Jet. Can not test with your provider. BTW in
first case, without parameter, Stores_Account = 'test', in second case (with
parameter) - 'SHIP' (value of variable test). May be your table has row with
Stores_Account = 'test' and has no row with Stores_Account = 'SHIP'?

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Dale Williams" <dwilliams@yf.com> ???????/???????? ? ???????? ?????????:
news:41890d30$1@newsgroups.borland.com...
> Viatcheslav V. Vassiliev wrote:
>
> >>WHERE Stores_Account = ''?'''
> >
> >
> > Do not enclose ? in quotes - it becomes string value in this case.
> >
> > //------------------------------------------
> > Regards,
> > Vassiliev V. V.
> > http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
> > ADO.Net
> > http://www.oledbdirect.com - The fastest way to access MS SQL Server,
> > MS Jet (Access) and Interbase (through OLEDB)
> >
> > "Dale Williams" <dwilliams@yf.com> ???????/???????? ? ????????
?????????:
> > news:418900fa$1@newsgroups.borland.com...
> >
> >>Everyone:
> >>
> >>I have a fairly simple test program to pass a parameter to an SQL
> >>statement but doesn't work.  The app. only takes the results and binds
> >>them results to a data grid.
> >>
> >>When I run the program I don't receive any errors.  I just receive a
> >>empty datatable.
> >>
> >>If I use the following statement and don't setup a parameter, I receive
> >>data from the query and everything is fine.
> >>   cmd := System.Data.OleDb.OleDbCommand.Create('SELECT * FROM INSAS_REC
> >>WHERE Stores_Account = ' + ''''test'''', cnn);
> >>
> >>
> >>Here is the problem code:
> >>
> >>test := 'SHIP';
> >>
> >>   cnn :=
> >>System.Data.OleDb.OleDbConnection.Create('provider=connxoledb;Persist
> >>Security Info=True;prompt=no;Data
> >>Source=c:\AlphaYF.CDD;Location=RMS;User
> >>ID=connx;Password=*****;Mode=ReadWrite;');
> >>
> >>   cmd := System.Data.OleDb.OleDbCommand.Create('SELECT * FROM INSAS_REC
> >>WHERE Stores_Account = ''?''', cnn);
> >>
> >>cmd.Parameters.Add('a1', OleDbType.Char, 8).Value := test;
> >>da  := System.Data.OleDb.OleDbDataAdapter.Create(cmd);
> >>
> >>dt  := System.Data.DataTable.Create();
> >>
> >>da.Fill(dt);
> >>
> >>self.DataGrid1.DataSource := dt;
> >>self.DataGrid1.DataBind();
> >>
> >>Thanks for the help,
> >>Dale Williams
> >
> >
> >
> Thanks for the reply.
>
> I've tried that and it didn't work.
>  >>   cmd := System.Data.OleDb.OleDbCommand.Create('SELECT * FROM
> INSAS_REC WHERE Stores_Account = ?', cnn);
>
> Dale
Technical Details
Message-ID: <418a062e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <418900fa$1@newsgroups.borland.com> <418909a5$1@newsgroups.borland.com> <41890d30$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,a04cffef418afd36
X-Google-Attributes: gid1effe6,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.delphi.database.dotnet
References: <418900fa$1@newsgroups.borland.com> <418909a5$1@newsgroups.borland.com> <41890d30$1@newsgroups.borland.com>
Subject: Re: Passing Parameters using OleDb
Date: Thu, 4 Nov 2004 13:36:29 +0300
Lines: 86
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 213.234.218.42
Message-ID: <418a062e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1099564590 213.234.218.42 (4 Nov 2004 02:36:30 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail