CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Database

  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    Database

    Hi ;
    I m an C++/MFC Programmer and appreciate if someone could give me a small piece of code where I could connect to a Db via my ODBC Connection with some examples of doing a select query and storing the recordset results.

    1-In MFC there are classed like CDatabase or CRecordSet where it makes the whole job easier.
    There must be a similar thing in VB too.

    2-At the start of the creating the project Do i need to select a particular template to get the development Job easire or not.?


    Cheers


    Share what you know and ask what you dont....
    Using Java version on windows 1.8_51

  2. #2
    Join Date
    Feb 2002
    Location
    Italy
    Posts
    7

    Re: Database

    2- Yes.One way (I think the standard way)is :when you use connection to Database, in your project references you must add MicroSoft Active Data Object Library x.x.... (So You use ADO components). There is other ways... another could be use DAO components.

    1- When you choose how to connect to your database then you can use the proprieties of your connection type. Fo example for Ado you can use code like this:
    Dim cnn as ADODB.Connection
    or
    Dim rs as ADODB.Recordset
    ecc...

    Bye

    Al Sbano from Italy

    beginner in vb-world

  3. #3
    Join Date
    Aug 1999
    Location
    Romania, Bucharest
    Posts
    253

    Re: Database

    first add references to ADO from project menu and then put the following code into a form

    Set conn = New ADODB.Connection
    conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;Initial Catalog=YourCatalog;Data Source=YourServr;User ID=user;Password=pass;"
    conn.Open
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open "SELECT * FROM Table", conn

    let me know if this help




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