首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

BC30456: 'ExecuteReader' is not a member of 'System.Data.OleDb.OleDbDataAdapter'

2011-12-20 
BC30456: ExecuteReader is not a member of System.Data.OleDb.OleDbDataAdapter.个错误怎么解决呀本

BC30456: 'ExecuteReader' is not a member of 'System.Data.OleDb.OleDbDataAdapter'.个错误怎么解决呀
本来就没有几行程序,怎么找不到错误的原因啊.请高手帮帮忙.
在本面运行程序就提示
Compilation   Error  
Description:   An   error   occurred   during   the   compilation   of   a   resource   required   to   service   this   request.   Please   review   the   following   specific   error   details   and   modify   your   source   code   appropriately.  

Compiler   Error   Message:   BC30456:   'ExecuteReader '   is   not   a   member   of   'System.Data.OleDb.OleDbDataAdapter '.

Source   Error:

 

Line   21:   try
Line   22:   objConnection.open()
Line   23:   objDataReader   =   objCommand.ExecuteReader()
Line   24:   Label1.text   =   objDataReader( "tltle ")
Line   25:   Label2.text   =   objDataReader( "blog ")
 

============源程序============================
<%@   Page   Language= "VB "   ContentType= "text/html "   ResponseEncoding= "gb2312 "   debug= "true "   %>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Strict//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<%@   import   namespace= "system "%>
<%@   import   namespace= "system.data "%>
<%@   import   namespace= "system.data.oledb "%>
<script   language= "vb "   runat= "server ">
sub   page_load()
dim   objConnection   as   OleDbConnection
dim   objCommand   as   OleDbDataAdapter
dim   strConnect   as   String  
dim   strCommand   as   String
dim   objDataReader   as   OledbDataReader

strConnect   =   "Provider=Microsoft.Jet.OLEDB.4.0; "
strConnect   +=   "Data   Source=E:\Myproject\mystock\db\ "
strConnect   +=   "myaccont.mdb; "
strCommand   =   "select   title,blog   from   blog   order   by   id   desc "
objConnection   =   new   OleDbConnection(strConnect)
objCommand   =   new   OleDbDataAdapter(strCommand,objConnection)

try
objConnection.open()
objDataReader   =   objCommand.ExecuteReader()
Label1.text   =   objDataReader( "tltle ")
Label2.text   =   objDataReader( "blog ")
objDataReader.Close()
objConnection.Close()
catch   e   as   Exception
con_open.text   =   "connection   failed   to   open   successfully. <br> "
con_close.text   =   e.ToString()
end   try

end   sub
</script>
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "content-type "   content= "text/html;   charset=gb2312 "   />
<title> Quadrangle   by   Free   Css   Templates </title>
<meta   name= "keywords "   content= " "   />
<meta   name= "description "   content= " "   />
<link   href= "default.css "   rel= "stylesheet "   type= "text/css "   />


</head>
<body>
<div   id= "header ">
<h1> <a   href= "# "> STOCK </a> </h1>
<h2> <a   href= "http:// "> by   popo   </a> </h2>
</div>

<div   id= "content ">
    <div   id= "colOne ">
            <asp:Label     id= "con_open "   runat= "server "/> <br/>
<asp:Labelid= "con_close "   runat= "server "/> <br/>
        <asp:Label     id= "Label1 "   runat= "server "/> <br/>
<asp:Labelid= "label2 "   runat= "server "/>

    </div>
<div   style= "clear:   both; "> &nbsp; </div>
</div>


<div   style= "font-size:   0.8em;   text-align:   center; ">

</div>
</body>
</html>

[解决办法]
dim objCommand as OleDbCommand
not
dim objCommand as OleDbDataAdapter
[解决办法]
你只是执行一句命令,为何要用数据适配器呢??
[解决办法]

dim objCommand as OleDbDataAdapter
---------------------

应该是:
dim objCommand as OleDbCommand

--------------------

热点排行