1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Delphi 7 and SQL Server 2000

Discussion in 'Programming' started by odumitre, Mar 11, 2007.

  1. odumitre

    odumitre New Member

    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,
  2. dav

    dav New Member

    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
  3. odumitre

    odumitre New Member

    Thank you very much. It works perfect like that.

    You are wonderful.

    Best regards,
  4. dav

    dav New Member

    for nothing my friend ....................

Share This Page