ADO.NET, asp.net work
[ Pobierz całość w formacie PDF ]
Imports System.Data.SqlClientImports System.DataImports SystemPartial Class _DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadTryDim conn As SqlConnection = New SqlConnection()conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename= C:\SQL Server 2000 Sample Databases\NORTHWND.MDF ;Integrated Security=True;Connect Timeout=30;User Instance=True"Dim objSqlCommand As SqlCommand = New SqlCommand()objSqlCommand.Connection = connobjSqlCommand.CommandType = SqlDataSourceCommandType.TextobjSqlCommand.CommandText = "SELECT * FROM Categories ORDER BY CategoryID"Dim dataAdap As SqlDataAdapter = New SqlDataAdapter()Dim dataSet As DataSet = New DataSet()dataAdap.SelectCommand = objSqlCommanddataAdap.Fill(dataSet)GridView1.DataSource = dataSetGridView1.DataBind()conn.Open()'Label1.Text = "Liczba wierszy: " + (objSqlCommand.ExecuteScalar()).ToString()conn.Close()Catch ex As ExceptionResponse.Write("Wyst?pi? b??d: " + ex.Message)End TryEnd SubEnd Class
[ Pobierz całość w formacie PDF ]