🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Passing Parameters using OleDb

#602
From: Viatcheslav V. Vassiliev
Date: Wed, 03 Nov 2004 16:39
54 lines
2576 bytes
> 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
Technical Details
Message-ID: <418909a5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <418900fa$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>
Subject: Re: Passing Parameters using OleDb
Date: Wed, 3 Nov 2004 19:39:01 +0300
Lines: 56
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: <418909a5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1099499941 213.234.218.42 (3 Nov 2004 08:39:01 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail