Esempio n. 1
0
    public static SqlConnection GetDBConnection()
    {
        string datasource = @"DESKTOP-5QPRQC5\SQLEXPRESS";
        string database   = "BizappsTest";

        return(DBSQLServerUtils.GetDBConnection(datasource, database));
    }
Esempio n. 2
0
            public static SqlConnection GetDBConnection()
            {
                string datasource = @"laptop-j5h40kmv";

                string database = "Year2";

                return(DBSQLServerUtils.GetDBConnection(datasource, database));
            }
Esempio n. 3
0
        public static SqlConnection GetDBConnection()
        {
            string datasource = @"DESKTOP-5TGIQQC\SQLEXPRESS";
            string database   = "RG_database";
            string username   = "******";
            string password   = "******";

            return(DBSQLServerUtils.GetDBConnection(datasource, database, username, password));
        }
Esempio n. 4
0
        public static SqlConnection GetDBConnection()
        {
            string datasource = @"IP\SQLEXPRESS";

            string database = "simplehr";
            string username = "******";
            string password = "******";

            return DBSQLServerUtils.GetDBConnection(datasource, database, username, password);
        }
Esempio n. 5
0
        public static SqlConnection GetDBConnection()
        {
            string datasource = @"127.0.0.1";

            string database = "PolitDV";
            string username = "******";
            string password = "******";

            return(DBSQLServerUtils.GetDBConnection(datasource, database, username, password));
        }
Esempio n. 6
0
        public static SqlConnection GetDBConnection()
        {
            string datasource = @"DESKTOP-RPK6PAD\SQLEXPRESS";

            string database = "QuanLyBanHang";
            string username = "******";
            string password = "******";

            return(DBSQLServerUtils.GetDBConnection(datasource, database, username, password));
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            SqlConnection connection = DBSQLServerUtils.GetDBConnection();

            connection.Open();
            try
            {
                // Команда Insert.
                string sql = "Insert into Salary_Grade (Grade, High_Salary, Low_Salary) "
                             + " values (@grade, @highSalary, @lowSalary) ";

                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = sql;

                // Создать объект Parameter.
                SqlParameter gradeParam = new SqlParameter("@grade", SqlDbType.Int);
                gradeParam.Value = 3;
                cmd.Parameters.Add(gradeParam);

                // Добавить параметр @highSalary (Написать короче).
                SqlParameter highSalaryParam = cmd.Parameters.Add("@highSalary", SqlDbType.Float);
                highSalaryParam.Value = 20000;

                // Добавить параметр @lowSalary (Написать короче).
                cmd.Parameters.Add("@lowSalary", SqlDbType.Float).Value = 10000;

                // Выполнить Command (Используется для delete, insert, update).
                int rowCount = cmd.ExecuteNonQuery();

                Console.WriteLine("Row Count affected = " + rowCount);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
                connection = null;
            }

            Console.Read();
        }