Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:02:25+00:00 2026-06-10T23:02:25+00:00

I would like to connect to the MS SQL Server 2008 during installation. There’s

  • 0

I would like to connect to the MS SQL Server 2008 during installation. There’s a similar question, which offers a solution by using isql.exe tool, which is not compatible with SQL Server 2008.

Could you suggest, how to connect to a MS SQL Server 2008 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:02:27+00:00Added an answer on June 10, 2026 at 11:02 pm

    Here is a simple example for connecting to Microsoft SQL Server using ADO:

    [Setup]
    AppName=My Program
    AppVersion=1.5
    DefaultDirName={pf}\My Program
    DefaultGroupName=My Program
    UninstallDisplayIcon={app}\MyProg.exe
    Compression=lzma2
    SolidCompression=yes
    
    [Code]
    const
      adCmdUnspecified = $FFFFFFFF;
      adCmdUnknown = $00000008;
      adCmdText = $00000001;
      adCmdTable = $00000002;
      adCmdStoredProc = $00000004;
      adCmdFile = $00000100;
      adCmdTableDirect = $00000200;
      adOptionUnspecified = $FFFFFFFF;
      adAsyncExecute = $00000010;
      adAsyncFetch = $00000020;
      adAsyncFetchNonBlocking = $00000040;
      adExecuteNoRecords = $00000080;
      adExecuteStream = $00000400;
      adExecuteRecord = $00000800;
    var
      CustomerLabel: TLabel;
      ConnectButton: TButton;
    
    procedure ConnectButtonClick(Sender: TObject);
    var
      Name, Surname: string;
      SQLQuery: AnsiString;  
      ADOCommand: Variant;
      ADORecordset: Variant;
      ADOConnection: Variant;  
    begin
      try
        // create the ADO connection object
        ADOConnection := CreateOleObject('ADODB.Connection');
        // build a connection string; for more information, search for ADO
        // connection string on the Internet 
        ADOConnection.ConnectionString := 
          'Provider=SQLOLEDB;' +               // provider
          'Data Source=Default\SQLSERVER;' +   // server name
          'Initial Catalog=Northwind;' +       // default database
          'User Id=UserName;' +                // user name
          'Password=12345;';                   // password
        // open the connection by the assigned ConnectionString
        ADOConnection.Open;
        try
          // create the ADO command object
          ADOCommand := CreateOleObject('ADODB.Command');
          // assign the currently opened connection to ADO command object
          ADOCommand.ActiveConnection := ADOConnection;
          // load a script from file into the SQLQuery variable
          if LoadStringFromFile('d:\Script.sql', SQLQuery) then
          begin
            // assign text of a command to be issued against a provider
            ADOCommand.CommandText := SQLQuery;
            // this will execute the script; the adCmdText flag here means
            // you're going to execute the CommandText text command, while
            // the adExecuteNoRecords flag ensures no data row will be get
            // from a provider, what should improve performance
            ADOCommand.Execute(NULL, NULL, adCmdText or adExecuteNoRecords);
          end;
          // assign text of a command to be issued against a provider
          ADOCommand.CommandText := 'SELECT Name, Surname FROM Customer';
          // this property setting means, that you're going to execute the 
          // CommandText text command; it does the same, like if you would
          // use only adCmdText flag in the Execute statement
          ADOCommand.CommandType := adCmdText;
          // this will execute the command and return dataset
          ADORecordset := ADOCommand.Execute;
          // get values from a dataset using 0 based indexed field access;
          // notice, that you can't directly concatenate constant strings 
          // with Variant data values
          Name := ADORecordset.Fields(0);
          Surname := ADORecordset.Fields(1);
          CustomerLabel.Caption := Name + ' ' + Surname;
        finally
          ADOConnection.Close;
        end;
      except
        MsgBox(GetExceptionMessage, mbError, MB_OK);
      end;
    end;
    
    procedure InitializeWizard;
    begin
      ConnectButton := TButton.Create(WizardForm);
      ConnectButton.Parent := WizardForm;
      ConnectButton.Left := 8;
      ConnectButton.Top := WizardForm.ClientHeight - 
        ConnectButton.ClientHeight - 8;
      ConnectButton.Caption := 'Connect';
      ConnectButton.OnClick := @ConnectButtonClick;
      CustomerLabel := TLabel.Create(WizardForm);
      CustomerLabel.Parent := WizardForm;
      CustomerLabel.Left := ConnectButton.Left + ConnectButton.Width + 8;
      CustomerLabel.Top := ConnectButton.Top + 6;
      CustomerLabel.Font.Style := [fsBold];
      CustomerLabel.Font.Color := clMaroon;
    end;
    

    Here is my testing SQL script file stored in my case as Script.sql:

    BEGIN TRANSACTION;
    BEGIN TRY
        CREATE TABLE [dbo].[Customer](
            [ID] [int] IDENTITY(1,1) NOT NULL,
            [Name] [nvarchar](50) NOT NULL,
            [Surname] [nvarchar](50) NOT NULL,
            [CreatedBy] [nvarchar](255) NOT NULL,
            [CreatedAt] [datetime] NOT NULL,
        CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
          ([ID] ASC)
        WITH 
          (
            PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
            ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON
          ) ON [PRIMARY]
        ) ON [PRIMARY]
        
        ALTER TABLE [dbo].[Customer] 
          ADD CONSTRAINT [DF_Customer_CreatedBy] DEFAULT (suser_sname()) FOR [CreatedBy]
        
        ALTER TABLE [dbo].[Customer] 
          ADD CONSTRAINT [DF_Customer_CreatedAt]  DEFAULT (getdate()) FOR [CreatedAt]
          
        INSERT INTO [dbo].[Customer]
          (Name, Surname)
        VALUES
          ('Dave', 'Lister')
    END TRY
    BEGIN CATCH
        IF @@TRANCOUNT > 0
            ROLLBACK TRANSACTION;
    END CATCH;
    
    IF @@TRANCOUNT > 0
        COMMIT TRANSACTION;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to a remote SQL server. I would like to
I would like to use F# to connect to databases other than SQL Server
Possible Duplicate: Change Notification with Sql Server 2008 Am just wondering is there's anyway
Can I connect to SQL Server 2008 using PDO and integrated security using the
I have an application running in IIS which connects to a SQL Server 2008
I have a large (~ 40gb ) SQL Server 2008 database that I would
I am trying to connect to a SQL Server 2008 database through a C#
I am trying to connect to SQL Server 2008 (not express) with PHP 5.2.9-2
I'm having some trouble with a SQL Server 2008 R2 (Express) installation. It seems
I would like to be able to connect an Oracle database with a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.