ASP.NET 2.0数据库外文文献及翻译和参考文献 第5页
the Customers table of contents of the database data bundled with GridView control gvCustomers:
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'Start by determining the connection string value
DimconnStringAsString= ConfigurationManager.ConnectionStrings(connStringName).ConnectionString
'创建一个SqlConnection实例
Using myConnection As New SqlConnection(connString)
'指定SQL查询
Const sql As String = "SELECT * FROM Customers"
'创建一个SqlCommand实例
Dim myCommand As New SqlCommand(sql, myConnection)
'取回一个DataSet
Dim myDataSet As New DataSet
'创建一个SqlDataAdapter查询
Dim myAdapter As New SqlDataAdapter(myCommand)
myAdapter.Fill(myDataSet)
'把DataSet绑定到GridView
gvCustomers.DataSource = myDataSet
gvCustomers.DataBind()
'关闭连接
myConnection.Close()
End Using
End If
End Sub
Here, attention should be paid to a few points: In order to be connected string, we can refer to Web.config in connection string settings - for use syntax
ConfigurationManager.ConnectionStrings (connStringName). ConnectionString. One, connStringName the value should be in Sql data source control wizard (CustomersConnectionString) of the steps specified in value. Also note, Visual Basic 8 (2.0 used in the本文来自辣文论文网原文请找QQ752018766 VB version) now supports Using keywords - and this is in front of the version of the C # only suitable for the characteristics of a language.
Programming access to data and the output equivalent to the use of Sql data source control the situation.
6. Conclusion
In this paper, we analyzed th毕业论文
http://www.751com.cne Visual Studio 2005 in the use of ASP.NET 2.0 database of cases. We discussed how to Visual Studio database management, and how to App_Data folder to add a site-specific database. Finally, we analyzed how to use Sql data source controls and programming approach to access data. When using a data source control, by setting the DataSourceID GridView attribute to the data tied to a GridView control on when to visit the data programming, data through the assignment to the GridView DataSource properties and call the DataBind GridView () Method to achieve the data binding to the GridView. (The latter approach followed in ASP.NET 1.x used in the model to bind data to a DataGrid.) Regardless of which use a form to access data, the final result, as in a user's browser can see in the , Are the same.
上一页 [1] [2] [3] [4] [5]
ASP.NET 2.0数据库外文文献及翻译和参考文献 第5页下载如图片无法显示或论文不完整,请联系qq752018766