CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    388

    Opening database table with an SQL query

    I have worked with databases with m_strFilter variable and it works nice, but now I need to open a database table, with a complete SQL query. I suppose I have to do this by passing the sql string in Open() function. Can somebody give a little code for this!


  2. #2
    Guest

    Re: Opening database table with an SQL query

    If you're using SQL, the DBMS makes a difference. I'll assume you're using Oracle, and give you code for that. First you connect to the database with:

    EXEC SQL CONNECT :hv_szUserId
    IDENTIFIED BY :hv_szPasswd
    USING :hv_szHostId;



    Once you've got a connection to the database, perform whatever function you'd like. For example, to query the databse, you can select a first name where the last name is smith from the Names table.

    SELECT firstName
    FROM Names
    WHERE lastName = 'Smith';



    Is that what you were looking for?



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