2

こんにちは、私はOracle DBに非常に慣れていないので、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:protocol adapter error

コンピューターに tnsnames.ora ファイルもありますが、接続時にそれを使用する必要があるかどうか (または、そもそもどのように使用するか) がわかりません。上記のコードに必要ですか?

DB への DNS レス接続を使用しようとしています。それがこれで何をしているのかわからないのですか?

どんな助けでも素晴らしいでしょう!!! :o)

デビッド

4

2 に答える 2

3

多くの方法があります: 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

于 2011-01-26T15:34:11.357 に答える
1

DB への新しい接続文字列を作成する必要があるとき、および接続文字列の形式が頭の中にないときは、常にwww.connectionstrings.com/を使用します。

于 2011-01-27T13:28:50.210 に答える