您的位置:首页 > 其它

Access data layer study notes.

2007-08-13 17:17 393 查看

INSERT INTO [Products] ([ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued]) VALUES (@ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued);




SELECT SCOP_IDENTITY();
----which will return the last identity value inserted into an IDENTITY column in the same scope. (See the technical documentation for more information about SCOPE_IDENTITY()




public partial class Northwind
{
public partial class SuppliersRow
{
public Northwind.ProductsDataTable GetProducts()
{
ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
return productsAdapter.GetProductsBySupplierID(this.SupplierID);
}
}
}

<ItemTemplate>
<asp:BulletedList ID="BulletedList1" runat="server" DataSource='<%# ((Northwind.SuppliersRow)((System.Data.DataRowView) Container.DataItem).Row).GetProducts() %>'
DataTextField="ProductName">
</asp:BulletedList>
</ItemTemplate>

We define a function GetProducts in class SuppliersRow which is generater by vs automately , but this sample add a function . this amazing me .

let us analyse how to use this function in typed dataset(强类型)。 because this is function is use in class Northwind.SuppliersRow , so in the Html we have to convert it to this type .but I also want to know how to got the data , we must learn form this ((Northwind.SuppliersRow)((System.Data.DataRowView) Container.DataItem).Row).GetRowducts().

many knowledage I need to master .

delete and update nonqury retrun type will return a int value reprents the numuber of row it affect .

insert although it will return a value , but the bype is boject . I must take caer of this.

nonqury retrun type is int .

scalar return type is object .

that's all , I know all about this , nothing have to doubt.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: