要做个简易博客网站,主页上要在页面截稿时显示一存在数据库里的文章
Dim myconnstring As String = "provider=microsoft.jet.oledb.4.0;data source= " & Server.MapPath( "blog.mdb ")
Dim myconnection As OleDbConnection
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim sqlstr As String = "select * from blog order by datetime "
Try
myconnection = New OleDbConnection(myconnstring)
Dim mycommand As OleDbCommand = New OleDbCommand(sqlstr, myconnection)
myconnection.Open()
Dim mydatareader As OleDbDataReader = mycommand.ExecuteReader()
Do While (mydatareader.Read)
Dim articlestr As String
articlestr = mydatareader.GetString(2)
Label2.Text = articlestr
Loop
myconnection.Close()
Catch ex As Exception
End Try
End Sub
------解决方案--------------------------------------------------------
你怎么知道,不是发生错误,导致网页没有任何改变呢???
------解决方案--------------------------------------------------------
楼主怎么知道没有执行到,设个断点看下,没有取到数据的可能性更大
另外把Page_Load事件里的绑定代码放在
If Not IsPostBack Then
...
End If
里面
------解决方案--------------------------------------------------------
设断点,调试!
------解决方案--------------------------------------------------------
事件丢失?
VB。NET中好象很少出现
倒是C#03很容易出现的问题
------解决方案--------------------------------------------------------