Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie
From: MikeB (m.byerleyATVerizonDottieNettie)
Date: 12/27/03
- Next message: Tonia: "Re: Programming for mobile phones."
- Previous message: BedBaol: "Include Excel code"
- In reply to: sara cox: "How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Next in thread: sara cox: "Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Reply: sara cox: "Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Dec 2003 12:51:28 -0500
DSN-Less connection. DBQ can be passed or get from INI file. Fields collection accesed by ordinal
number or Name.
uses ADODB_TLB;
procedure TForm1.Button1Click(Sender: TObject);
var
RS, CN: OleVariant;
sSql, sCnStr : string;
i : Integer;
begin
sSql := 'SELECT * from Shippers';
sCnStr := 'Provider=MSDASQL.1;Driver={Microsoft Access Driver
(*.mdb)};Dbq=f:\Access\Samples\NWind2K.mdb;Uid=admin;Pwd=';
CN := CreateOleObject('ADODB.Connection');
CN.Open(sCnStr);
RS := CreateOleObject('ADODB.Recordset');
RS.ActiveConnection := CN;
RS.CursorLocation := adUseClient;
RS.CursorType := adOpenKeyset;
RS.LockType := adLockOptimistic;
RS.Open(sSql);
RS.Addnew;
RS.Fields['CompanyName'].value := 'My New Shipper';
RS.Fields['Phone'].value := '(555)555-1212';
//RS.Fields[1].value := 'My New Shipper';
//RS.Fields[2].value := '(555)555-1212';
RS.MoveFirst;
RS.Update;
RS.Close;
end;
"sara cox" <saracox2004@yahoo.com> wrote in message
news:e6c9da04.0312262154.972f3f7@posting.google.com...
> Hi!
>
> I am a newbie and I would like to add records to an MS Access DB using
> Delphi and ADO within a DLL I wrote in Delphi 7.
>
> I have a DSN connection. I (obviously) don't want to use a form - the
> DLL is accessed through C# / .NET and it sends a string of data which
> needs to be committed to the Access DB.
>
> Right now the DLL is working and I can pass a string to it and it pops
> up with a message box with the string.
>
> Do I use a unit in delphi? A function? A procedure?
>
> If you can supply me with some simple sample code, I would greatly
> appreciate it. Thanks in advance!
>
> Sara :)
> xoxo
- Next message: Tonia: "Re: Programming for mobile phones."
- Previous message: BedBaol: "Include Excel code"
- In reply to: sara cox: "How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Next in thread: sara cox: "Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Reply: sara cox: "Re: How do I add a record to an MS Acess DB using Delphi and ADO? Newbie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]