CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2001
    Location
    maharashtra,india
    Posts
    181

    Connection through coding

    how can i connect adodc and oracle database throught coding
    plzz help me out


  2. #2
    Join Date
    Feb 2001
    Posts
    54

    Re: Connection through coding

    Hello
    Here is some code that can do it:


    private Sub Command2_Click() 'Allow SQL query
    Adodc1.RecordSource = "Select " & Text3.Text & _
    " from " & Text4.Text & _
    " WHERE " & Text5.Text & "=" & Text6.Text
    Adodc1.Refresh
    End Sub





    'This opens Oracle. The user has to input thier userid and password

    private Sub Command3_Click()
    Adodc1.ConnectionString = "Provider=MSDAORA. 1;Password=" & Text2.Text & ";User ID=" & Text1.Text & ";Persist Security Info=true"
    Adodc1.CommandType = adCmdUnknown
    End Sub




    I hope this will help.


  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Connection through coding

    This topic has been discussed fairly often in this forum. Please do a search, either on ADODC or DATABASE itself to get the information.

    The simples way is to add "Microsoft ADO Data Control x.x" into your project (COMPONENTS). Then add the ADODC component into your form (by default it will be called ADODC1). Right click on it and the wizard will come up for you to build the CONNECTION STRING. You can also use a UDL file or attach via ODBC.

    For ORACLE connection, you MUST HAVE the Oracle Client installed on the computer and the TNSNAMES.ORA containing the alias (SERVICE NAME) to the server. The wizard will request for the service name, username and password.

    Hope this helps,
    -Cool Bizs

    Good Luck,
    -Cool Bizs

  4. #4
    Join Date
    Aug 2001
    Location
    Bangalore,India
    Posts
    13

    Re: Connection through coding

    Try This,

    dim con as Adodb.connection
    dim rs as Adodb.recordset

    Private Sub Form_Load()
    con.connectionstring=uid=YourUsername;pwd=Yourpassword;DSN=YourDsnName;
    con.open
    rs.open "select *from YourTableName",con,2,3
    End Sub

    end sub




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured