扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:csdn 2007年11月6日
关键字: ASP.NET 数据库 SqlDataSource Windows
<asp:SqlDataSource ID="MySourceControlName" Runat="server" ConnectionString="Server=MyServer ; Database=Northwind" SelectCommand=" SELECT Fieldl, [Field With Space] FROM MyTable"> </asp:SglDataSource> |
<asp:SqlDataSource ID="MySourceControlName" Runat="server" ConnectionString=" Server=MyServer ; User ID=MyID; Password=Mypass; Database=Northwind" SelectCommand=" SELECT Field1, [Field With Space] FROM MyTable"> </asp:SqlDataSource> |
SelectCommand="SELECT * from MyView"> |
SelectCommand="SELECT * from [My View] " |
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtmlll/DTD/xhtmlll.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Ch03-Tio#l-SqlSimple-verl</title> </head> <body> <h2> Chapter 3 TIO #1 SqlSimple verl </h2> <form id="forml" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSourcel" Runat="server" ProviderName="System.Data.SqlClient" ConnectionString="Server=(local)\SQLExpress; Integrated Security=True; Database=Northwind; Persist Security Info=True" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice] FROM[Products]"> </asp:SqlDataSource> <asp:GridView ID="GridViewl" Runat="server" DataSourceID="SqlDataSourcel" DataKeyNames="ProductID" AutoGenerateColumns="False"> <Columns> <asp:BoundField ReadOnly="True" HeaderText="ProductID" InsertVisible="False" DataField="ProductID" SortExpression=" ProductID" ></asp: BoundField> <asp:BoundField HeaderText="ProductName"DataField="ProductName" SortExpression="ProductName"></asp:BoundField> <asp:BoundField HeaderText="UnitPrice" DataField="UnitPrice" SortExpression="UnitPrice"></asp:BoundField> </Columns> </asp:GridView> </div> </form> </body> </html> |
... <asp:SqlDataSource ID="SqlDataSourcel" Runat="server" <asp:GridView ID="GridViewl" Runat="server" ... <asp:GridView ID="GridView2" Runat="server" DataSourceID="SqlDataSource2" DataKeyNames="CategoryID" AutoGenerateColumns="False" EmptyDataText="There are no data records to display."> <Columns> <asp:BoundField ReadOnly="True" HeaderText="CategoryID" DataField="CategoryID" SortExpression="Category ID"></asp:BoundField> <asp:BoundField HeaderText="CategoryName"DataField="CategoryName" SortExpression="CategoryMame"></asp:BoundField> <asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description"></asp:BoundField> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource2" Runat="server" ProviderName="<%$ ConnectionStrings:AppConnectionString2 . ProviderName %>" ConnectionString="<%$ ConnectionStrings:AppConnectionString2 %>" SelectCommand="SELECT[CategoryID],[CategoryName] ,[Desc- ription] FROM [Categories]" UpdateCommand="UPDATE[Categories]SET[CategoryName]=@CategoryName, [Description] = @Description WHERE[CategoryID]=@original_CategoryID" InsertCommand="INSERT INTO[Categories]([CategoryName],[Description] VALUES (@CategoryName, @Description)" DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = @original_CategoryID"> <DeleteParameters> <asp:Parameter Type="Int32" Name="CategoryID"></asp:Parameter> </DeleteParameters> <InsertParameters> <asp:Parameter Type="String"Name="CategoryName"></asp:Parameter> <asp: Parameter Type="String" Name="Description"></asp: Parameter> </InsertParameters> <UpdateParameters> <asp:Parameter Type="String" Name="CategoryName"></asp:Parameter> <asp:ParameterType="String" Name="Description"></asp:Parameter> <asp:Parameter Type="Int32"Name="CategoryID"></asp:Parameter> </UpdateParameters> </asp:SqlDataSource> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者