Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to create database in sql server with code

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) Button1: TButton; ADOConnection1: TADOConnection; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin // First you connect to sql server AdoConnection.connected := true; // then ADOCommand1.CommandText := 'Create DataBase Saves '+ 'On '+ '(Name = databasename, '+ 'FileName = '+QuotedStr('C:\database.MDF')+', '+ 'Size = 50MB, '+ //first size 'FileGrowth = 30MB) '+ //growth size in MB 'Collate Arabic_CI_AI ';// unicode change to arabic or other unicode ADOCommand1.Execute; end; end.