vb.net 中ADODB.Recordset报错,该怎么解决
vb.net 中ADODB.Recordset报错
代码是以前别人写的,现在要修改一个功能,把原来代码整到我机器上,配置好编译通过,但是调试时出现了一些问题:1、已经添加引用:ADODB,ADOX;
.vb中代码如下(窗体设计器生成代码和Page_Load没有写):
Public Class AddressBookMain
Inherits System.Web.UI.Page
Public Rst As ADODB.Recordset
Public iCount As Integer
Public Function GetDataConn() As ADODB.Connection
Dim Con As New ADODB.Connection
Con.ConnectionTimeout = 30
Con.CommandTimeout = 1 * 3600
Con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Con.Open(Application.Contents.Item("strDSN"))
GetDataConn = Con
End Function
Public Function GetDepartMainList() As Boolean
Dim Cmd As New ADODB.Command
Dim strSql As String
Cmd.ActiveConnection = Me.GetDataConn()
strSql = "select [ID],RTrim(isnull(DepName,'')) as DepName from dbo.DepartMent where iSort=1 order by Sort"
Cmd.CommandText = strSql
Cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
Rst = Cmd.Execute
GetDepartMainList = True
End Function
在.aspx中脚本代码:
<%
If Me.GetDepartMainList() = True Then
Me.iCount=0
Do While Not Rst.EOF
If Me.iCount mod 4 = 0 Then
%>
编译通过,启动调试进入页面的时候就报这样的错误:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30652: 需要对程序集“ADODB”(包含类型“ADODB.Recordset”)的引用。请在项目中添加一个。
源错误:
行 162: If Me.GetDepartMainList() = True Then
行 163: Me.iCount=0
行 164: Do While Not Rst.EOF
行 165: If Me.iCount mod 4 = 0 Then
行 166: %>
数据库应该连接上去了,而且这个程序原来是能用的。跑到我机器上就不能用了。奇怪啊,高手请帮忙解决下。非常感谢。
------解决方案--------------------
.net已经不用recordset了当然报错了,原来运行是因为有6.0的库,现在可能没有了,就不能运行了,你还是用新的吧
代码是以前别人写的,现在要修改一个功能,把原来代码整到我机器上,配置好编译通过,但是调试时出现了一些问题:1、已经添加引用:ADODB,ADOX;
.vb中代码如下(窗体设计器生成代码和Page_Load没有写):
Public Class AddressBookMain
Inherits System.Web.UI.Page
Public Rst As ADODB.Recordset
Public iCount As Integer
Public Function GetDataConn() As ADODB.Connection
Dim Con As New ADODB.Connection
Con.ConnectionTimeout = 30
Con.CommandTimeout = 1 * 3600
Con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Con.Open(Application.Contents.Item("strDSN"))
GetDataConn = Con
End Function
Public Function GetDepartMainList() As Boolean
Dim Cmd As New ADODB.Command
Dim strSql As String
Cmd.ActiveConnection = Me.GetDataConn()
strSql = "select [ID],RTrim(isnull(DepName,'')) as DepName from dbo.DepartMent where iSort=1 order by Sort"
Cmd.CommandText = strSql
Cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
Rst = Cmd.Execute
GetDepartMainList = True
End Function
在.aspx中脚本代码:
<%
If Me.GetDepartMainList() = True Then
Me.iCount=0
Do While Not Rst.EOF
If Me.iCount mod 4 = 0 Then
%>
编译通过,启动调试进入页面的时候就报这样的错误:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30652: 需要对程序集“ADODB”(包含类型“ADODB.Recordset”)的引用。请在项目中添加一个。
源错误:
行 162: If Me.GetDepartMainList() = True Then
行 163: Me.iCount=0
行 164: Do While Not Rst.EOF
行 165: If Me.iCount mod 4 = 0 Then
行 166: %>
数据库应该连接上去了,而且这个程序原来是能用的。跑到我机器上就不能用了。奇怪啊,高手请帮忙解决下。非常感谢。
------解决方案--------------------
.net已经不用recordset了当然报错了,原来运行是因为有6.0的库,现在可能没有了,就不能运行了,你还是用新的吧