编译时遇到的问题,请教各位(20分)

  • 主题发起人 主题发起人 启吾
  • 开始时间 开始时间

启吾

Unregistered / Unconfirmed
GUEST, unregistred user!
使用者可以在文字输入盒中输入SQL陈述,并会显示所输入的叙述影响资料源的笔数
<%@Import Namespace=System.Data.ADO%>
<%@Import Namespace=System.Data%>
<Html>
<Form id="F1" Runat="Server">
请输入SQL陈述:<Input Type="Text" Id="Text1" Runat="Server">
<Button ID="Button1" Runat="Server" OnServerClick="Button1_Click">
执行
</Button>
</Form>
<Span ID="Sp1" Runat="Server"/>
<Script Language="VB" Runat="Server">
Sub Button1_Click(sender as object, e as eventargs)
Dim cnA as ADOConnection=New ADOConnection
dim cmA as ADOCommand=New ADOCommand

cnA.Provider="Microsoft.Jet.OLEDB.4.0"
cnA.DataSource="C:/web/MyWeb.mdb"
cnA.UserID="Admin"
cnA.Open()
cmA.ActiveConnection=cnA
cmA.CommandType=Commandtype.Text
cmA.CommandText=Text1.Value
cmA.Execute()
Sp1.InnerText="这个叙述影响了" &amp;
cmA.RecordsAffected &amp;
"笔资料"
End Sub
</Script>
</Html>
但我执行的时候显示编译错误:
编译器错误信息: BC30002: 未定义类型“ADOConnection”。
行 16: Dim cnA as ADOConnection=New ADOConnection
但我已经声明了:<%@Import Namespace=System.Data.ADO%>
<%@Import Namespace=System.Data%>
望高手指点!
 
現在應該沒有ADOConnection這個控件才對
給你看個例子。
Public Sub CreateMyOleDbCommand()
Dim myConnection As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=NWIND_RW.MDB")
myConnection.Open()
Dim myTrans As OleDbTransaction = myConnection.begin
Transaction()
Dim mySelectQuery As String = _
"SELECT * FROM Categories ORDER BY CategoryID"
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection, myTrans)
myCommand.CommandTimeout = 20
End Sub
 
后退
顶部