อันนี้เป็นโค๊ตนะครับ มัน Connect base ได้ แต่แสดงข้อมูลไม่ได้อ่ะครับ
Code (VB.NET)
Imports System.Data
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\WebAppdBase\App_Data;Extended Properties=dBASE IV;User ID=Admin;Password=;"
objConn = New OleDbConnection(strConnString)
objConn.Open()
Call BindData()
If objConn.State = ConnectionState.Open Then
lblText.Text = "Access Connected"
Else
lblText.Text = "Access Connect Failed"
End If
End Sub
Sub BindData()
Dim strSQL As String
strSQL = "SELECT * FROM dBase2"
Dim dtReader As OleDbDataReader
objCmd = New OleDbCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to Repeater ***'
gvShow.DataSource = dtReader
gvShow.DataBind()
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
objConn.Close()
objConn = Nothing
End Sub
End Class
Tag : ASP.NET Web (ASP.NET), VB.NET, VS 2010 (.NET 4.x)