![]() |
|
|
|
#1
|
||||
|
||||
|
Connect from VB6 or .NET to Oracle SQL 8
Hi all!
I want to ask you if anyone worked on a similar project. I want to code a simple querry aplication in VB6 or .NET that connect to a Oracle SQL server from a client station. This is what SQL consola display: Quote:
I wonder if anyone can help me to solve this issue. Thank you! |
|
#2
|
|||
|
|||
|
Try this:http://www.vbcode.com/default.htm, there are 8 pages with threads about oracle in the section Database
|
|
#3
|
|||
|
|||
|
Either install the oracle instant client or install the full oracle client with odbc support.
Suppose you install the full client which I usually do to c:\oracle then you can find a filename tnsadmin.ora, this one contains the settings to your databases (for remote and local databases). Check out www.orafaq.com/wiki/Tnsnames.ora for details. here you need to add your database names. Be aware that remote databases must of course have the correct ip and correct port number and sid (your dbadmin should know those). For a local db you can use the example given (check the port numebr tho). Have oracle in your path and reboot (if needed). Start your c:\oracle\bin\sqlplusw.exe and enter your username, password and sid. If this does not work then you have a setting wrong or your firewall is stopping you. Basically it should work. After that you should be able to get your oracle working via odbc or via .net drivers fairly easy. You can use ms access or a free tool like foxysql or freesql to check that. You can use the microsoft odbc driver for oracle but also the oracle odbc driver from oracle itself (which is what I prefer). The difference between the two is that a timestamp datatype doesnt work properly in the microsoft version and that a clob and blob seem to work somewhat different in the microsoft compared to the oracle driver. I myself always prefer the microsoft odbc driver. This should get you started quickly. The instantclient can be set up easily as well but you'd miss some of the tools that are handy. But setting up both will cause trouble so be warned.. |
|
#4
|
|||
|
|||
|
The following codes using odbc��u can try it.
connect server Public Function ConnectServer(ByVal ServerName As String, ByVal DBName As String, ByVal UserName As String, ByVal PWD As String) As Boolean Dim ConnectString As String On Error GoTo Error_ConnectServer rdoEngine(0).CursorDriver = rdUseClientBatch ConnectString = "Driver={Microsoft ODBC For Oracle};Server=" & DBName & "_" & ServerName & ";UID=" & UserName & ";PWD=" & PWD & ";" Set grdoCN = rdoEngine(0).OpenConnection("", rdDriverNoPrompt, False, ConnectString) ', rdAsyncEnable) ConnectServer = True Exit Function Error_ConnectServer: ConnectServer = False End Function connect oracleserver Public Function ConnectOracleServer(ByVal ServerName As String, ByVal DBName As String, ByVal UserName As String, ByVal PWD As String) As Boolean Dim strConnect As String On Error GoTo Error_ConnectOracleServer strConnect = "Driver={Microsoft ODBC For Oracle};Server=" & DBName & "_" & ServerName & ";UID=" & UserName & ";PWD=" & PWD & ";" adoORACLEConnect.Open strConnect ConnectOracleServer = True Exit Function Error_ConnectOracleServer: ConnectOracleServer = False End Function |
|
#5
|
||||
|
||||
|
Before starting anything i make a clarify.
I use Oracle8i Enterprise Edition Release 8.1.7.0.0 The network is based on a server. All the clients connect and work on server on the LAN. I have a client station with the client software already installed and i work on client interface. Before thinking to connect via ODBC drivers i take a look here: Quote:
I am wrong? For connecting to database with third party tools i use Lotus Approach and select "Microsoft ODBC for Oracle" driver. I can connect to database of course because i work dayly on this platform from a client staion. My question is how to setup the Visual Basic 6 or Visual Basic .NET to connect to the database because i want to develop a simple app that does small querryes on the database. From what i read on www all methots involve Oracle SQL 9.xx or greater and from what tuts or faqs i followed none aplly to my case. That is why i try to contect persons who can lead me or tell me what i do wrong. |
![]() |
|
|