Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create database on local MS SQL Server 2000 Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Create database on local MS SQL Server 2000 14-Apr-04
Category
Database-SQL
Language
Delphi 5.x
Views
234
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jason Madden 

How to Create database on local MS SQL Server 2000?

Answer:
1   
2   procedure CreateDatabase(WindowsSecurity: Boolean; Username, Password: string);
3   var
4     ConnectionString: string;
5     CommandText: string;
6   begin
7     if WindowsSecurity then
8       ConnectionString := 'Provider=SQLOLEDB.1;' +
9         'Integrated Security=SSPI;' +
10        'Persist Security Info=False;' +
11        'Initial Catalog=master'
12    else
13      ConnectionString := 'Provider=SQLOLEDB.1;' +
14        'Password=' + Password + ';' +
15        'Persist Security Info=True;' +
16        'User ID=' + Username + ';' +
17        'Initial Catalog=master';
18  
19    try
20  
21      try
22        ADOConnection.ConnectionString := ConnectionString;
23        ADOConnection.LoginPrompt := False;
24        ADOConnection.Connected := True;
25  
26        CommandText := 'CREATE DATABASE test ON ' +
27          '( NAME = test_dat,    ' +
28          'FILENAME = ''c:\program files\microsoft sql server\mssql\data\test.mdf'', 
29  '+
30          'SIZE = 4, ' +
31          'MAXSIZE = 10, ' +
32          'FILEGROWTH = 1 )';
33  
34        ADOCommand.CommandText := CommandText;
35        ADOCommand.Connection := ADOConnection;
36        ADOCommand.Execute;
37        MessageDlg('Database succesfully created.', mtInformation, [mbOK], 0);
38  
39      except
40        on E: Exception do
41          MessageDlg(E.message, mtWarning, [mbOK], 0);
42      end;
43  
44    finally
45      ADOConnection.Connected := False;
46      ADOCommand.Connection := nil;
47    end;
48  
49  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC