Access to Delphi 5

I have a small database in Acess 2000
that I would like to convert to Delphi enviroment.How?
srbenavrbeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

florisbCommented:
I could provide you with some comments, but do you just want to use an Access database (easy enough to use in dbgrid / navigator, et cetera). Or do you have a lot of functionality in Access you want to convert? I don't think you can automate this process, I would like to know if I'm wrong.

Floris.

0
intheCommented:
well i hope this is what your after.

how to connect to msaccess db via odbc:

to set up Odbc:

1:   Open Control Panel, and then select ODBC DataSources (32bit) .
2:   When the Data Source Administrator appears, Click Add.
3:   find the one that says  Microsoft Access Driver (*.mdb)
     click it and click finish.
4:   A dialog will popup called ODBC Microsoft Access Setup
5:   in "data source name" edit box well call it "MyAccess"
6:   description well say is "tesing msaccess connection".
7:   click select and find your .mdb file click ok to select it.
8:   click "advanced" and make sure login name and password are blank.
9:   close advanced.
10:  close microsoft access setup dialog
11:  close the  Data Source Administrator.

to set up delphi side:

1:  start or restart delphi if its already running.
2:  start a new project
3:  drop a ttable,tdbgrid,tdatasource,tdatabase on form.

    in object inspector:

4:  datasource1 dataset : table1
5:  dbgrid datasource   : datasource1
6:  database1 aliasname : MyAccess  
7:  database1 databasename : MyDB //type a free given name
8:  database1 loginprompt : false
9:  table1 databasename : MyDB  //MyDB is now selectable
10: table1 tablename : select a table
11: database1 connected : true
12: table1 active : true

now you work with db as normal..
Regards Barry
0
srbenavrbeAuthor Commented:
Inthe : nice answer!
Have everything running,well almost...
In Access my two fields are
1.)Question
2.)Answer
and are memo type.Now in Delphi in
dbGrid i have under those fields (memo)
displayed????.
So how do I get this resolved?I would like to have on my form everything displayed as in the Access form (and not  dbGrid ).Can it be done?

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

intheCommented:
hi,
there is 4 choices:

1:
change the feilds to type text in access ;-)(but text is probably limits to 50 chars)

2:use tdbgrids by assigning datasource and datafeild propertys.

3: there are a couple of third party components that support it but the better ones are shareware although there is a free one take a look at www.torry.ru under components \ grids.
try to find TDBGridPlus by Javier Tari Agullo ,if i find first i post link here.might find it easier at delphi super page.


4:

this will work but it only displays the first 50 characters:

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);
var
Buf: array [0..51] of Char;
BS: TBlobStream;
S: String;
begin
{Check to see if currently-drawn field is a memo field}
if Field is TMemoField then begin
{Create the TBlobStream object}
BS := TBlobStream.Create(TMemoField(Field), bmRead);
try
{Fill buffer with nulls}
FillChar(Buf, 51, #0);
{Read 50 characters from memo field into buffer}
BS.Read(Buf, 50);
{Copy from null-terminated buffer to Pascal String}
S := StrPas(Buf);
{Cosmetic: show that data is continued}
S := S + '...';
{Put a null character in place of any carriage-returns}
while (Pos(#13, Buf) > 0) do
S[Pos(#13, Buf)] := #0;
{Draw String to grid's Canvas within cell's boundaries}
with TDBGrid(Sender).Canvas do begin
{Clear current cell}
FillRect(Rect);
{Draw String text}
TextOut(Rect.Left, Rect.Top, S);
end;
finally
{Destroy TBlobStream object connected to current record}
BS.Free;
end;
end;
end;


really it depends on how many chars you will need it this feild ,if less than 50 then the drawcell method will suffice.
Regards Barry

0
intheCommented:
Hi
here is link to free comp that displays the text instead of (Memo) ,i tested it and seems to work well enough,it was wrote originally for d2 but installed in d4 no probs so should be also ok in d5.:

http://www.torry.webnorth.com/vcl/database/dbgrdpls.zip

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
srbenavrbeAuthor Commented:
Well I have resolved most of my troubles but some remain...
To display information mentioned, I have used Data control components
(DBEEdit and DBMemo).Just linked them to the right datasource and
datafield and it works.Well,almost....
What puzzles me is this:
If I have a field in Access that is autonumber type,should not Delphi
behave accordingly?Well,it does not!I have a field that is autonumber
but when I run delphi app. no change is visible.Why...I do not know.
Also the date field....I think that when Delphi displays the form it
should display info. from Access (there the field is set to current
date ( =Date() ).Delphi leaves the field empty...
Well,I will not bother you with these funny details of everyday
life....
Also I have a combobox field in Access but Delphi will not display
its contents....
Ahhh....like I said....never mind....
What I wanted to know,now I know....

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.