🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Accessing SQL Data Delphi Syntax

#19
From: Wayne Niddery [TeamB]
Date: Fri, 02 Feb 2007 22:07
45 lines
2511 bytes
Wes wrote:
> I am trying to access data from a SQL database and I cannot figure
> out the syntax for it using BDS 2006 in a .NET aspx. I am using the
> Delphi style syntax, not C#.
>
> Here is what I have so far:
>
> var
>   connDarters : sqlConnection;

// define a reader:
    rdr: SQLDataReader;
//[...]
>        connDarters.Open;
>        sqlState.Connection := connDarters;
>        sqlState.CommandText := 'select STATE from StateTable order by
> STATE';
>        sqlState.ExecuteReader;

// Above line needs to assign the reader result:
        rdr := sqlState.ExecuteReader;

// Now you can loop the returned rows:
        while rdr.Read do
        begin
>
> // This is whare further code most likely should be placed to fill in
> the drop-down
>
>        ddlState.Items.Add('TX');  // This was just a test to see if
> some data showed up in the drop-down. It worked.

          ddlState.Items.Add(rdr.Item['state'].ToString);
        end;

The alternative is to use a data adapter instead of a command object, use 
that to Fill a Dataset, and then just bind the dropdown to the dataset.


-- 
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"The legitimate powers of government extend to such acts only as are
injurious to others. But it does me no injury for my neighbor to say
there are twenty gods, or no God. It neither picks my pocket nor breaks
my leg." � Thomas Jefferson 
Technical Details
Message-ID: <45c3b5e3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45c38651$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,37f179b7946f073
X-Google-Attributes: gid1effe6,public
X-Google-Language: ENGLISH,ASCII
Reply-To: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca>
From: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca>
Newsgroups: borland.public.delphi.database.dotnet
References: <45c38651$1@newsgroups.borland.com>
Subject: Re: Accessing SQL Data Delphi Syntax
Date: Fri, 2 Feb 2007 17:07:33 -0500
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 69.17.150.141
Message-ID: <45c3b5e3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1170453987 69.17.150.141 (2 Feb 2007 14:06:27 -0800)
X-Authenticated-User: wniddery
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail