示例#1
0
        private void XoaSachBang()
        {
            string      delete = "Delete from tblPGN";
            clsDatabase cls    = new clsDatabase();

            cls.Execute_NonQuery(delete);
        }
示例#2
0
        private void SaveFormToDatabase(string Tablename)
        {
            try
            {
                if (richTextBox1.Text.Trim() == "")
                {
                    MessageBox.Show("rickTextBox CHUA CO NOI DUNG!");
                    return;
                }
                string      sql = " SELECT * FROM information_schema.tables where table_name ='" + Tablename + "'";
                clsDatabase cls = new clsDatabase();
                int         kq  = cls.Execute_Scalar(sql);
                if (kq == 0)
                {
                    string createTable = "USE [WORK_WITH_PGN_FILE]" +
                                         "GO" +
                                         /****** Object:  Table [dbo].[tblPGN]    Script Date: 10/02/2014 11:18:14 ******/
                                         "SET ANSI_NULLS ON" +
                                         "GO" +
                                         "vSET QUOTED_IDENTIFIER ON" +
                                         "GO" +
                                         "CREATE TABLE [dbo].[" + Tablename + "](" +
                                         "[ID] [bigint] IDENTITY(1,1) NOT NULL," +
                                         "[Events] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         " [Site] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[Date] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[Rounds] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[White] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[Black] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         " [Result] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[WhiteElo] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[BlackElo] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "[ECO] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         " [Plays] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL," +
                                         "CONSTRAINT [PK_tblPGN] PRIMARY KEY CLUSTERED " +
                                         "(" +
                                         " [ID] ASC" +
                                         ")WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]" +
                                         ") ON [PRIMARY]";
                    cls.Execute_NonQuery(createTable);
                }
                string[] ReadFromRickTextBox = richTextBox1.Text.Trim().Split('\n');

                string[] Output = ExecuteStringArray(ReadFromRickTextBox);
                SaveStringToDatabase(Output, Tablename);
                MessageBox.Show("Thanh Cong!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }