SELECT * FROM SCORE WHERE COURSE = '物件導向程式設計' SELECT * FROM SCORE WHERE COURSE LIKE '%程式設計%' SELECT * FROM SCORE ORDER BY SCORE DESC ================================ --SQL註解1 /*SQL註解2*/ ================================ --別名 SELECT S.COURSE FORM SCORE S =============================== --合併表格 INNER JOIN SELECT P.NAME, S.SID, S.SCORE, S.COURSE FROM SCORE S INNER JOIN STUDENT P ON S.SID = P.SID --簡化寫法 SELECT P.NAME, S.SID, S.SCORE, S.COURSE FROM SCORE S, STUDENT P WHERE S.SID = P.SID ================================== --LEFT OUTTER JOIN SELECT P.NAME, S.SID, S.COURSE, S.SCORE FROM SCORE S, LEFT OUTTER JOIN STUDENT P ON S.SID = P.PID --RIGHT OUTTER JOIN SELECT P.NAME, S.SID, S.COURSE, S.SCORE FROM SCORE S, RIGHT OUTTER JOIN STUDENT P ON S.SID = P.PID --FULL OUTTER JOIN SELECT P.NAME, S.SID, S.COURSE, S.SCORE FROM SCORE S, FULL OUTTER JOIN STUDENT P ON S.SID = P.PID
INSERT..() VALUE..() INSERT SCORE (SID, COURSE, SCORE) VALUES ('S001', '程式設計', 86) INSERT SCORE (SID, COURSE, SCORE) VALUES ('A003', '程式設計', 74) 由於各欄位不可為NULL,故語法可以省略為下: INSERT SCORE VALUE ('S002', '演算法', 77) INSERT SCORE VALUE ('S003', '演算法', 57) =============== UPDATE.. SET..= WHERE..= UPDATE SCORE SET COURSE = '物件導向程式設計', SCORE = 95 WHERE SID = 'S001' ================= DELETE FROM.. WHERE..= DELETE FROM SCORE WHERE SID = 'S003' ================= SELECT * FROM SCORE SELECT SID AS '學號', COURSE AS '科目名稱', SCORE AS '分數" FROM SCORE
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WebApplication1.Models; using WebApplication1.Services; namespace WebApplication1.Controllers { public class MessageController : Controller { messageDBService data = new messageDBService(); //實作Services的物件 (其含有兩個方法:1.取得資料庫資料並回傳 2.接收資料並寫進資料庫) // GET: Message public ActionResult Index() //執行Index檢視頁面 (首頁或索引頁面) { return View(data.GetData()); //將資料傳回View (使用方法1.) } public ActionResult Create() //執行Create檢視頁面 (新增資料的頁面) { return View(); } [HttpPost] //當瀏覽器發送HTTP POST請求才會執行 public ActionResult Create(string Article_title, string Content) //當使用Create這個Action且有帶參數時 { data.DBCreate(Article_title, Content); //把資料寫進資料庫 (使用方法2.) return RedirectToAction("Index"); //回到Index這個Action } } }
Interface: 定義為抽象的概念,與Class差別為,界面雖然有包含屬性與方法,但只宣告而不包含實作內容。 --類別只能"繼承"一個父類別,但能"實作"(語法跟繼承很像)多個介面。(老爸只能有一個,乾爹可以認很多個的概念) --類別實作介面時,只會得到方法的名稱,不會包含任何實作內容。
class Aaa{} //class類別 decimal Bbb(){} //method方法 int Ccc{get; set;} //property屬性 。不含set的屬性被視為唯讀 。不含get的屬性被視為唯寫 。同時具有這兩種存取子的屬性則為可讀寫
Console.WriteLine() 秀畫面並換行; Console.Write() 秀畫面;
========================
Console.Write(string.Format("{0}*{1}={2:00}\t", j, i, j * i)); //類矩陣的方式,定義每個值的顯示方式
>Entity Framework(often referred to as EF):
>a .NET Framework data-access technology to define and work with model classes.
>By default, the Entity Framework looks for a connection string named the same as the object context class (MovieDBContext for this project).
>Entity Framework is default to using LocalDB.
>LocalDB is a lightweight version of the SQL Server Express Database Engine
>LocalDB runs in a special execution mode of SQL Server Express that enables you to work with databases as .mdf files.
>Typically, LocalDB database files are kept in the App_Data folder of a web project.
>SQL Server Express is not recommended for use in production web applications.
>LocalDB in particular should not be used for production with a web application because it is not designed to work with IIS. However, a LocalDB database can be easily migrated to SQL Server or SQL Azure.
>Razor code註解符號 @*…….*@
>A controller class is where you write the code that handles the incoming browser requests, retrieves data from a database, and ultimately decides what type of response to send back to the browser.
>A view template should never perform business logic or interact with a database directly. Instead, a view template should work only with the data that’s provided to it by the controller. Maintaining this “separation of concerns” helps keep your code clean, testable and more maintainable.
>目前都是藉由Controller(藉由網址)傳遞資料給View(畫面呈現)