Re: CSV file and newb
From: MikeB (m.byerleyATVerizonDottieNettie)
Date: 02/03/04
- Next message: Nicholas Sherlock: "Re: Thin Client ID"
- Previous message: J French: "Re: Thin Client ID"
- In reply to: Rick Carter: "Re: CSV file and newb"
- Next in thread: MikeB: "Re: CSV file and newb"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 3 Feb 2004 13:11:31 -0500
I got this to work using a DSN, but couldn't get it to work DSN-Less (yet)
In the Uses: ADODB_TLB, ComObj, ActiveX
procedure TForm1.Button2Click(Sender: TObject);
var
CN,RS : OleVariant;
sCnStr : String;
begin
CN := CreateOleObject('ADODB.Connection');
RS := CreateOleObject('ADODB.Recordset');
sCnStr := 'Provider=MSDASQL.1;DSN=TestDelete;UID=Public;PWD=Public';
CN.Open(sCnStr);
RS.Open ('Select * From testdelete.csv', CN, adOpenStatic, adLockReadOnly,adCmdText);
RS.MoveFirst;
While Not RS.EOF do
begin
{ The file TestDelete.CSV had 18 columns
ShowMessage showed LastName, FirstName
}
ShowMessage(RS.Fields[2].value+ ', ' + RS.Fields[1].value);
RS.MoveNext;
end;
RS.Close;
RS := UnAssigned;
CN := UnAssigned;
end;
"Rick Carter" <carterrk@despammed.com> wrote in message
news:ad2aabdb.0402021807.136e369c@posting.google.com...
> "Dave" <wo_lfukNO@SPAMhotmail.com> wrote in message
news:<Z8ATb.43724$OA3.13942442@newsfep2-win.server.ntli.net>...
> > I have a csv file in the form "name","address", etc how can i read this file
> > and assign it to an edit box or format it into a memo in some kind of
> > sensible order. I'm using Delphi7 if this makes any difference.
>
> You don't say if that's D7 Personal, Pro, Enterprise, or Architect.
> If it's at least Pro, and you have some experience with databases or
> are ready
> to learn (the learning curve is fairly steep), I believe there's a way
> for the BDE to work with text files. Or, there are ways to convert it
> to a table; one
> is to load the csv file into Excel, insert a first row with headers
> (field names), and do a "save as" to a dBASE (.dbf) table.
>
> Other alternatives (also available for Personal): One is to use a
> freeware
> database engine available from http://www.mylittlebase.org/
>
> Another alternative is to work with StringLists, and particularly to
> use
> their CommaText property. I have a sample app for using
> comma-delimited
> text to populate a ListView, and I've also added a way to edit the
> data.
> I suppose I could zip up and mail you a copy, if you're interested.
>
> Rick Carter
> Chair, Paradox/Delphi SIG, Cincinnati PC Users Group
- Next message: Nicholas Sherlock: "Re: Thin Client ID"
- Previous message: J French: "Re: Thin Client ID"
- In reply to: Rick Carter: "Re: CSV file and newb"
- Next in thread: MikeB: "Re: CSV file and newb"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]