您的位置:首页 > 编程语言 > VB

[VB.NET]出错 ExecuteReader: CommandText 属性尚未初始化 帮忙看下 在线等!

2008-12-28 15:30 465 查看



出错 ExecuteReader: CommandText 属性尚未初始化 帮忙看下 在线等!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapter As SqlDataAdapter
Dim ds As DataSet = New DataSet
Dim myconn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings( "connectionString ").ToString)
Dim aa As String = Request( "l ")
Dim bb As String = Request( "value ")
Dim cc As String = Request( "i_x ")
Dim dd As String = Request( "i_aa ")
Dim constr As String
If aa = Request( "k1 ") Then
constr = "Select * from CompanyContent where companyname like ''% " & bb & "% '' order by companyid desc "
End If
If aa = Request( "k2 ") Then
If cc = "全市搜索 " Then
constr = "Select * from CompanyContent where companyname like ''% " & bb & "% '' order by companyid desc "
Else
constr = "Select * from CompanyContent where companyname like ''% " & bb & "% ''and companyaddress= '' " + cc + " '' order by companyid desc "
End If
End If
adapter = New SqlDataAdapter(constr, myconn)
adapter.Fill(ds, "Orders ")
Dim pp As New PagedDataSource
pp.DataSource = ds.Tables( "Orders ").DefaultView
pp.AllowPaging = True
pp.PageSize = 20
Dim nPageCount As Integer ''保存总共的数据页面数目
Dim a = ds.Tables( "Orders ").Rows.Count ''保存记录总数
Dim nPage As Integer ''存放要浏览当前数据页面号
If pp.PageCount Mod pp.PageSize > 0 Then
nPageCount = a / pp.PageSize
nPageCount += 1
End If
nPage = Convert.ToInt32(Request.QueryString( "Page "))
If Request.QueryString( "Page ") < 1 Then
nPage = 1
End If
If Request.QueryString( "Page ") > nPageCount Then
nPage = nPageCount
End If
pp.CurrentPageIndex = nPage - 1
lblPageCount.Text = "总共 " & a.ToString() + "条纪录 "
lblmsg.Text = ( "  " & "页次: " & nPage.ToString() & "/ " & nPageCount.ToString())
lblmsg.Text += ( "  数据导航: 首 页 ")
'' If Not pp.IsFirstPage Then
lblmsg.Text += ( " 上一页 ")
'' End If
'' If Not pp.IsLastPage Then
lblmsg.Text += ( " 下一页 ")
'' End If
lblmsg.Text += ( " 尾 页 ")
dstmsg.DataSource = pp
dstmsg.DataBind()
End Sub

好象是定义string的错把
__________________________________________________________________________
有人能帮忙看下吗?
__________________________________________________________________________
请参考: http://www.xproer.com/bbs/revert.aspx?fid=3&tid=615 __________________________________________________________________________
没看懂
__________________________________________________________________________
看一下是SQL语句,表名、列名是否匹配。
__________________________________________________________________________
是2005么,请把

Dim myconn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings( "connectionString ").ToString)

改为

Dim myconn As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings( "connectionString ").ToString)
__________________________________________________________________________
匹配的 我总感觉Dim constr As String 他错了
__________________________________________________________________________
2003
__________________________________________________________________________
那您看一下运行时constr里值到底是什么吧。
__________________________________________________________________________
constr 肯定为空
__________________________________________________________________________
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐