error in vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nandhanvijay
    New Member
    • Apr 2007
    • 17

    error in vb.net

    hi friends

    i have return a program to fetch the data from oracle. its shows error. here is my program

    [CODE=vbnet]
    imports System.Data.Ole DB
    Public Class Form1
    Inherits System.Windows. Forms.Form
    Dim myConnection As OleDbConnection
    Dim myCommand As OleDbCommand
    Dim dr As New OleDbDataReader ()
    'declaration
    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    myConnection = New OleDbConnection ("Provider=MSDA ORA.1;UserID=sc ott;password=ti ger; database=ora")
    'MSDORA is the provider when working with Oracle
    Try
    myConnection.Op en()
    'opening the connection
    myCommand = New OleDbCommand("S elect * from emp", myConnection)
    'executing the command and assigning it to connection
    dr = myCommand.Execu teReader()
    While dr.Read()
    'reading from the datareader
    MessageBox.Show ("EmpNo" & dr(0))
    MessageBox.Show ("EName" & dr(1))
    MessageBox.Show ("Job" & dr(2))
    MessageBox.Show ("Mgr" & dr(3))
    MessageBox.Show ("HireDate" & dr(4))
    'displaying data from the table
    End While
    dr.Close()
    myConnection.Cl ose()
    Catch ex As Exception
    End Try
    End Sub
    End Class
    [/CODE]

    its showing the error states that
    Type 'System.Data.Ol eDb.OleDbDataRe ader' has no constructors
    kindly help me

    Regards
    vijay
    Last edited by debasisdas; Jan 25 '08, 05:39 AM. Reason: formatted using code=vbnet tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to use this code

    [CODE=vbnet]
    imports System.Data.Ole DB
    Public Class Form1
    Inherits System.Windows. Forms.Form
    Dim myConnection As OleDbConnection
    Dim myCommand As OleDbCommand
    Dim dr As New OleDbDataReader
    'declaration
    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    myConnection = New OleDbConnection ("Provider=MSDA ORA.1;UserID=sc ott;password=ti ger; database=ora")
    'MSDORA is the provider when working with Oracle
    Try
    myConnection.Op en()
    'opening the connection
    myCommand = New OleDbCommand("S elect * from emp", myConnection)
    'executing the command and assigning it to connection
    dr = myCommand.Execu teReader()
    While dr.Read()
    'reading from the datareader
    MessageBox.Show ("EmpNo" & dr(0))
    MessageBox.Show ("EName" & dr(1))
    MessageBox.Show ("Job" & dr(2))
    MessageBox.Show ("Mgr" & dr(3))
    MessageBox.Show ("HireDate" & dr(4))
    'displaying data from the table
    End While
    dr.Close()
    myConnection.Cl ose()
    Catch ex As Exception
    End Try
    End Sub
    End Class
    [/CODE]

    Comment

    Working...