mj168
asked on
How do you use OleDb inside a class file?
I have a class file using VB in an ASP.Net website. In that file there is a subroutine that will delete a record from a table in the database. The problem that I am having is that OleDb methods and properties generate the message below:
"OleDb...... is not defiened"
The class file code is below.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---
<%@ Import Namespace="System.Data" %>
Public Class Class2
Sub RemoveTutorFromAllQueues()
Dim mySelectQuery2 As String = ""
Dim myConnectionString2 As String = ""
Dim myConnection2 As New OleDbConnection(myConnecti onString2)
Dim myCommand2 As New OleDbCommand(mySelectQuery 2, myConnection2)
myConnection2.Open()
Dim myReader2 As OleDbDataReader = myCommand2.ExecuteReader
myConnection2.Close()
End Sub
End Class
-------------------------- ---------- ---------- ---------- ---------- ---------- ---
How do you define OleDb properties, methods, etc in a class file?
"OleDb...... is not defiened"
The class file code is below.
--------------------------
<%@ Import Namespace="System.Data" %>
Public Class Class2
Sub RemoveTutorFromAllQueues()
Dim mySelectQuery2 As String = ""
Dim myConnectionString2 As String = ""
Dim myConnection2 As New OleDbConnection(myConnecti
Dim myCommand2 As New OleDbCommand(mySelectQuery
myConnection2.Open()
Dim myReader2 As OleDbDataReader = myCommand2.ExecuteReader
myConnection2.Close()
End Sub
End Class
--------------------------
How do you define OleDb properties, methods, etc in a class file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You shouldn't need to use full namespace path. Just simply import the System.Data.OleDb namespace as carl_tawn originally indicated.
ASKER
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
Generated an invalid charater error: '%'
<%@ Import Namespace="System.IO" %>
Generated an invalid charater error: '%'
ASKER
As for the other suggested method
Dim myCommand2 As New System.Data.OleDb.OleDbCon nection(my SelectQuer y2, myConnection2)
myCommand2 generated an error: 'no accessible New accepts this number of arguments'
and
Dim myReader2 As OleDbDataReader = myCommand2.ExecuteReader
OleDBDataReader generated an 'OleDbDataReader is not defined' error.
Dim myCommand2 As New System.Data.OleDb.OleDbCon
myCommand2 generated an error: 'no accessible New accepts this number of arguments'
and
Dim myReader2 As OleDbDataReader = myCommand2.ExecuteReader
OleDBDataReader generated an 'OleDbDataReader is not defined' error.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<%@ Import Namespace="System.Data.Ole