コード例 #1
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        private static DBMSSQL GetMSSQLDB()
        {
            //Private method to hold Connection String info for the database.

            DBMSSQL Db = new DBMSSQL(new DbConfig("dbName", "user", "password", "host"));

            return(Db);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        private static void DeleteStudent()
        {
            //Get db connection string.
            DBMSSQL Db = GetMSSQLDB();

            //Declare the delete statement.
            String Query = "DELETE From Student WHERE ID='4';";

            //Execute the query
            Db.NonQuery(Query);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        private static void UpdateStudent()
        {
            //Get db connection string.
            DBMSSQL Db = GetMSSQLDB();

            //Declare the update statement.
            String Query = "UPDATE Student SET LastName = 'Peters' WHERE ID='4';";

            //Execute the query
            Db.NonQuery(Query);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        private static void CreateStudent()
        {
            //Get db connection string.
            DBMSSQL Db = GetMSSQLDB();

            //Declare the insert statement.
            String Query = "INSERT INTO Student (ID,LastName, FirstName, StreetAddress) Values (4,'Murkel','Cliff','115 Niagara Ave');";

            //Execute the query
            Db.NonQuery(Query);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        public static object GetNumberOfStudents()
        {
            //Get db connection string.
            DBMSSQL Db = GetMSSQLDB();

            //Declare the scalar query.
            String Query = "Select COUNT(*) FROM Student;";

            //Pass the query to the scalar db method and execute the query.
            object StudentCount = Db.Scalar(Query);

            //return results.
            return(StudentCount);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: joshuakaluba/QueryExecutor
        public static List <Student> GetStudentInfo()
        {
            //Returns a list of student records.

            //Get db connection string.
            DBMSSQL Db = GetMSSQLDB();

            //Declare the query.
            String Query = "SELECT LastName, FirstName, StreetAddress from Student;";

            //Execute the query and store the query results from the database in a list.
            List <Student> Students = new List <Student>(Db.Query <Student>(Query));

            //return results.
            return(Students);
        }