예제 #1
0
        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
        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
        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
        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
        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
        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);
        }