Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   Delphi 7 and SQL Server 2000 (http://www.go4expert.com/forums/delphi-7-sql-server-2000-t3353/)

odumitre 12Mar2007 00:31

Delphi 7 and SQL Server 2000
How can I connect to a SQL Server database through a Delphi 7 application using ADO?
Which are the steps to follow to link a field from a table from a SQL Server database to a control, like DBEdit. I want to use A general form and a Data Module. What controls should I put on every form and which connections/links should I establish between them.

Thank you,

dav 16Mar2007 01:30

Re: Delphi 7 and SQL Server 2000
may be I have some errors cause I am writing this while I have niether Delphi or SQL SERVER on this computer so it is like writing in the dark
for the form only put a DBEdit
for the Datamodule u have to put
1. ADOConnection
2. ADOTable
3. DataSource
you start with the ADOConnection by clicking on the ConnectionString property so you get a dialogbox on which you choose use connection string and then you click on the button Build
so u get another dialog with 4 pages go to the page of provider which is the default and first page and choose Microsoft SQL SERVER and click next and u will find urself in the page of connection u have 2 select or enter the server name if u r not on a network u can write (local) or if u r on a network u have to choose the name ur SQL Server
if u use winXP u choose Windows NT integrated security or u have to write down ur user name and password then go and select the database from the combobox below which shows all the databases on the chosen server and click on test connection button if the connection succedded then u click ok to return to the first dialog and then another ok

do not forget to set the active property to true and to the login propt to false in the ADOConnection

next step will be with the ADOTable select it and set its connection property to refer to ur ADOConnection
then go to Table Name property and choose the table u want from the Database u have chosen while you were initializing the ADOConnection (u will c a list that shows all the posible tables) choose one
set active property of the table to true
now double click the ADOtable u will have a little form represents the list of field rigth click on it and choose show all fields
this will imports the whole field of ur table close it and get sure that the table still active

now go to the datasource and click on its Dataset property and choose ur ADOTable

now go to the general form add the unit of the Datamodule to the uses and then select the dbEdit
file the DBEdits property Datasource with the name of ur datasource
fill the datafield property with the name of the field u want (u will have a list to choose from)

that is all

I'll be ready for any more qestions about this

bon corrage

best regards

odumitre 16Mar2007 16:50

Re: Delphi 7 and SQL Server 2000
Thank you very much. It works perfect like that.

You are wonderful.

Best regards,

dav 16Mar2007 23:45

Re: Delphi 7 and SQL Server 2000
for nothing my friend ....................

All times are GMT +5.5. The time now is 17:39.