日期:2014-05-20  浏览次数:20471 次

新手的菜问题,为什么提示BC30451: Name 'data_src' is not declared.
照书上的例子写下来.运行时提示错误,是什么原因啊.在线等..
--------------------
<%@   import   namespace= "system.data "%>
<%@   import   namespace= "system.data.oledb "%>
<script   language= "vb "   runat= "server ">
sub   page_load(sender   as   object,E   as   eventArgs)
dim   objConnection   as   OleDbConnection
dim   strConnect   as   String
dim   strCommand   as   String

strConnect   =   "Provider=Microsoft.Jet.OLEDB.4.0; "
strConnect   =   "Data   Source=E:\Myproject\db "
strConnect   =   "myaccont.mdb; "
strConnect   =   "Persist   Security   Info=False "
data_src.text   =   strConnect

objConnection   =   new   OleDbConnection(strConnect)

try
objConnection.open()
con_open.text   =   "connection   opened   successfully. <br/> "
objConnection.Close()
con_close.text   =   "connection   closed. <br/> "
catch   e   as   exception
con_open.text= "connection   failed   to   open. <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> 无标题文档 </title>
</head>
<body>
<h4>   Testing   the   data   connection
<asp:Label   id= "con_src "   runat= "server "   /> </h4>
<asp:Label   ID= "con_open "   runat= "server "/>
<asp:Label   ID= "con_clse "   runat= "server "/>

</body>
</html>

------解决方案--------------------
<asp:Label id= "con_src " runat= "server " /> 改成 <asp:Label id= "data_src " runat= "server " />