DataAdapter屬性內的指令

1 DeleteCommed

DeleteCommand 是一個用於指定從資料庫刪除資料的 SQL 命令,通常與 SqlDataAdapter 搭配使用。

DELETE FROM [Products]

WHERE (([ProductID] = @Original_ProductID) AND ([ProductName] = @Original_ProductName) AND ([Discontinued] = @Original_Discontinued))

2 InsertCommand

InsertCommand 是一個用於指定將新資料插入資料庫的 SQL 命令,通常與 SqlDataAdapter 搭配使用。

INSERT INTO [Products] ([ProductName],

[Discontinued]) VALUES (@ProductName, @Discontinued); SELECT ProductID, ProductName, Discontinued FROM Products

WHERE (ProductID = SCOPE_IDENTITY())

3 SelectCommand

SelectCommand 是一個用於指定從資料庫查詢資料的 SQL 命令,通常與 SqlDataAdapter 搭配使用。

SELECT ProductID, ProductName, Discontinued FROM Products

4 UpdateCommnad

UpdateCommand 是一個用於指定更新資料庫中現有資料的 SQL 命令,通常與 SqlDataAdapter 搭配使用。

UPDATE [Products] SET [ProductName] = @ProductName, [Discontinued] = @Discontinued WHERE (([ProductID] = @Original_ProductID) AND ([ProductName] = @Original_ProductName) AND ([Discontinued] = @Original_Discontinued)); SELECT ProductID, ProductName, Discontinued FROM Products WHERE (ProductID = @ProductID)

ConnationString連線字串:

connectionString 是用來定義資料庫連線資訊的字串,包括伺服器、資料庫、驗證方式等。/tog

查詢產生器精靈:

Windows Forms 的查詢產生器精靈是一個可視化工具,幫助你建立 SQL 查詢,無需手動編寫 SQL 語句。

實作練習: