使用VB.net连接到Oracle 10g DB的字符串

嘿所有我对Oracle数据库都很陌生,我试图通过VB.net 2010连接到它。我一直在尝试以下方法:
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim dr As OleDbDataReader

    myConnection = New OleDbConnection("Provider=MSDAORA.1;UserID=xxxx;password=xxxx; database=xxxx")
    'MSDORA is the provider when working with Oracle
    Try
        myConnection.Open()
        'opening the connection
        myCommand = New OleDbCommand("Select * from emp", myConnection)
        'executing the command and assigning it to connection
        dr = myCommand.ExecuteReader()
        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.Close()
    Catch ee As Exception
    End Try
我收到了Catch ee As Exception系列的错误:ORA-12560:TNS:协议适配器错误 我的计算机上也有一个tnsnames.ora文件,但我不确定在连接时是否需要使用它(或者实际上,首先是如何)?它是否需要上面的代码? 我正在尝试使用DNS-Less连接到数据库。不确定这是不是在做什么? 任何帮助都会很棒!!! :O) 大卫     
已邀请:
有很多方法:我几乎每次使用的那种方式都不需要在TNSNAMES.ORA中输入是这样的:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
如果您不需要OleDb连接,我认为您应该使用System.Data.OracleClient或任何其他免费提供程序(如DevArt dotConnect for Oracle Express) 资料来源:http://www.connectionstrings.com/oracle     
当我需要为数据库创建一个新的连接字符串并且连接字符串格式不在我的头顶时,我总是使用www.connectionstrings.com/。     

要回复问题请先登录注册