1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
String createSQL; // variable contenant les requetes SQL pour créer les tables
String MyConnectionString = "Data Source=" + placeDatabase + " persist security info=false;";
SqlCeEngine MySqlCeEngine = new SqlCeEngine(MyConnectionString);
SqlCeConnection MySqlCeConnection = new SqlCeConnection(MyConnectionString);
try
{
MySqlCeEngine.CreateDatabase();
MySqlCeEngine.Dispose();
MySqlCeConnection.Open();
SqlCeCommand MySqlCeCommand;
MySqlCeCommand = MySqlCeConnection.CreateCommand();
MySqlCeCommand.CommandType = System.Data.CommandType.Text;
#region Create table : Identification
createSQL = "CREATE TABLE [dbo].[Identification](";
createSQL += "[FLAG] [smallint] NULL,";
createSQL += "[ID] [int] NOT NULL DEFAULT ((2147483647)),";
createSQL += "[nom] [varchar](50) COLLATE French_CI_AS NULL,";
createSQL += "[password] [varchar](16) COLLATE French_CI_AS NULL,";
createSQL += "[droits] [smallint] NULL,";
createSQL += "[afficher] [smallint] NULL DEFAULT ((1)),";
createSQL += "[email] [varchar](100) COLLATE French_CI_AS NULL,";
createSQL += "[telephone] [varchar](16) COLLATE French_CI_AS NULL,";
createSQL += "[vehiculeID] [int] NULL,";
createSQL += "[doitSynchroniser] [smallint] NULL,";
createSQL += ") ON [PRIMARY]";
createSQL += "CONSTRAINT [pk_Identification] PRIMARY KEY CLUSTERED ";
createSQL += "(";
createSQL += "[ID] ASC";
createSQL += ")WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]";
createSQL += ") ON [PRIMARY]";
#endregion
MessageBox.Show(createSQL);
MySqlCeCommand.CommandText = createSQL;
MySqlCeCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Form Except = new formExcetption(ex.Message);
Except.Show();
}
finally
{
if (MySqlCeConnection == null)
MySqlCeConnection.Close();
} |
Partager