这里有熟悉ASP.NET 1.1的吗,有个简单问题想请教..我用的是codebehind模式
图片如下:
不知道这个错误如何修改,代码如下:
WebForm1.aspx.vb
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
Private Sub InitializeComponent()
End Sub
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
' Insert page code here
'Connect to DataBase via OleDb
Private Function ConnectionString() As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;Password="";" & _
"Data Source=C:\Documents and Settings\YangYongyu\My Documents\OleDb.mdb;" & _
"Persist Security Info=True"
End Function
'Query via SQL Statement
Private Function Query() As String
Return "SELECT * FROM USERS"
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put User Code to initialize the page here
If (IsPostBack()) Then Exit Sub
BindData(Query())
End Sub
'Bind data
Private Sub BindData(ByVal SQL As String)
[color=red]Dim Adapter As New OleDbDataAdapter(SQL, ConnectionString())[/color]
Dim DataSet As New DataSet
Adapter.Fill(DataSet, "Users")
DataGrid1.DataSource = DataSet.Tables("Users")
DataGrid1.DataBind()
End Sub
End Class
WebForm1.aspx:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>
WebForm1