| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 770 人关注过本帖
标题:未将对象引用设置到对象的实例 急!!!!!!急!!!请各位大虾求救呀
取消只看楼主 加入收藏
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
 问题点数:0 回复次数:2 
未将对象引用设置到对象的实例 急!!!!!!急!!!请各位大虾求救呀
出错: DropDownList1.DataSource = objds.Tables(" DropDownList1").DefaultView



Imports System.Data
Imports System.Data.oledb
Public Class WebForm1
    Inherits System.Web.UI.Page

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

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

    End Sub
    Protected WithEvents RadioButton12 As System.Web.UI.WebControls.RadioButton
    Protected WithEvents pagemode2 As System.Web.UI.WebControls.RadioButton
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    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
    Dim objconn As OleDbConnection
    Dim objcmd As OleDbDataAdapter
    Dim objds As DataSet
    Dim strsql, strdsn As String


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            strsql = "select distinct 作者 from 书籍1"
            strdsn = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("mydb.mdb")
            objconn = New OleDbConnection(strdsn)
            objcmd = New OleDbDataAdapter
            objcmd.TableMappings.Add("table", " DropDownList1")
            objcmd.SelectCommand = New OleDbCommand(strsql, objconn)
            objds = New DataSet(" DropDownList1")
            objcmd.Fill(objds)
            DropDownList1.DataSource = objds.Tables(" DropDownList1").DefaultView
            DropDownList1.DataBind()

           
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strau As String
        strdsn = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("mydb.mdb")
        objconn = New OleDbConnection(strdsn)
        strau = Trim(DropDownList1.SelectedItem.Text)
        strsql = "select * from 书籍1 where 作者= '" & strau & " '"
        objcmd = New OleDbDataAdapter
        objcmd.TableMappings.Add("table", "book2")
        objcmd.SelectCommand = New OleDbCommand(strsql, objconn)
        objds = New DataSet("book2")
        objcmd.Fill(objds)
        DataGrid1.DataSource = objds.Tables("book2").DefaultView
        DataGrid1.DataBind()

    End Sub
  
End Class

[[it] 本帖最后由 twtdd 于 2008-6-17 16:49 编辑 [/it]]

上题图片.jpg (35.2 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 实例 对象 
2008-06-17 16:47
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
得分:0 
请问那里出错了....小弟不胜感激
2008-06-17 16:50
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
得分:0 
谢谢了
2008-06-18 16:10
快速回复:未将对象引用设置到对象的实例 急!!!!!!急!!!请各位大虾求救呀
数据加载中...
 
   



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

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