| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 584 人关注过本帖
标题:这几行代码哪错了?
取消只看楼主 加入收藏
lsz3344
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2007-4-11
收藏
 问题点数:0 回复次数:0 
这几行代码哪错了?

Imports System.Data
Imports System.Data.SqlClient

Public Class read
Inherits System.Web.UI.Page
Dim conn As SqlConnection = New SqlConnection("database=new;uid=sa;pwd=;server=127.0.0.1")
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents printScript As System.Web.UI.HtmlControls.HtmlGenericControl

Dim ds As New DataSet

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents TimeLabel As System.Web.UI.WebControls.Label
Protected WithEvents AuthorLabel As System.Web.UI.WebControls.Label
Protected WithEvents PreviousLink As System.Web.UI.WebControls.Literal
Protected WithEvents NextLink As System.Web.UI.WebControls.Literal
Protected WithEvents numPages As System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'注意: 以下占位符声明是 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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Session("pass") <> "ok" Then
Response.Redirect("login.aspx")
End If
Dim str1 As String = "select * from message1 where caption='" & Session("caption") & "'"
Dim da As New SqlDataAdapter(str1, conn)
Dim ds As New DataSet
da.Fill(ds, "usertable")
Label1.Text = RTrim(ds.Tables("message1").Rows(0).Item("caption"))
TimeLabel.Text = RTrim(ds.Tables("message1").Rows(0).Item("date1"))
AuthorLabel.Text = RTrim(ds.Tables("message1").Rows(0).Item("name"))
Label2.Text = RTrim(ds.Tables("message1").Rows(0).Item("meat"))

End Sub

End Class



“/WebApplication1”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:


行 43: Dim ds As New DataSet
行 44: da.Fill(ds, "usertable")
行 45: Label1.Text = RTrim(ds.Tables("message1").Rows(0).Item("caption"))
行 46: TimeLabel.Text = RTrim(ds.Tables("message1").Rows(0).Item("date1"))
行 47: AuthorLabel.Text = RTrim(ds.Tables("message1").Rows(0).Item("name"))

搜索更多相关主题的帖子: 代码 
2007-05-12 22:01
快速回复:这几行代码哪错了?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015375 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved