Helpful Information
 
 
Category: .Net Development
OleDbDataReaders

Excuse the code, but can anyone tell me why im getting these errors, and how I can fix them?

All im wanting to do is send a select query to a database, knowing that 3 columns of data will come back..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



Dim myReader As OleDbDataReader()

Dim myOleDbConnection As OleDbConnection

Dim myOleDbCommand As OleDbCommand



myOleDbCommand = New OleDbCommand("SELECT POPUP.P_TYPE, POPUP.P_TITLE, POPUP.P_MSG FROM [POPUP] WHERE POPUP.P_TYPE='normal' AND POPUP.PID = (SELECT USRPOPLNK.PID FROM [USRPOPLNK] WHERE USRPOPLNK.UID = (SELECT USER.UID FROM [USER],[MACHINE] WHERE MACHINE.MID = USER.MID AND MACHINE.M_NAME='" & mname & "' AND MACHINE.M_DOMAIN='" & domain & "'))", OleDbConnection1)

'.NET Framework Error handling : Try, Catch, Finally Block

Try

myOleDbConnection.Open()

myReader = myOleDbCommand.ExecuteReader()***

Catch ex As Exception

OleDbConnection1.Close()

MsgBox(ex.ToString)



Finally

myReader.Close()***

myOleDbConnection.Close()



End Try



End Sub


The error messages that im getting are concerning the points marked with ***

And are as follows (in order that they appear in script)

H:\Agile\Agility\Form1.vb(294): Value of type 'System.Data.OleDb.OleDbDataReader' cannot be converted to '1-dimensional array of System.Data.OleDb.OleDbDataReader'.

H:\Agile\Agility\Form1.vb(300): 'Close' is not a member of 'System.Array'.



Thanks guys.

Chris

Assgin memory to DataReader with "new" opreator and then try again. DataReader , DataSet , and OleDBCommand do no work untill u assign them memory with new opreators as they are objects in .NET










privacy (GDPR)