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

出错 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 肯定为空 __________________________________________________________________________

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...