Connecting SQL Server 2000 and Visual Basic 6.0

  • Im fairly new to SQL Server but wish to create an application in VB (6.0) with a small SQL Server DB back end. Is this possible and easy to do?

    Cheers guys

    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • Hi Andrew,

    quote:


    Im fairly new to SQL Server but wish to create an application in VB (6.0) with a small SQL Server DB back end. Is this possible and easy to do?


    welcome back

    Getting a basic app skeleton using VB6 isn't really difficult.

    I think depending on your VB edition, you can choose from File-> New project the entry 'Data project'. VB add automatically references to ADO and to ADO controls. That's a basic start, but using ADO with VB is very well documented.

    However, be prepared to hand code more than say in Access.

    And the reporting engine in VB isn't by far that brilliant as Access Report Generator.

    And, as always, if you got any questions, come back and ask.

    Frank

    http://www.insidesql.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Cheers Frank......Basically the VB app is going to be a UI for the database.....does this make a difference to any methods ill need?

    quote:


    Hi Andrew,

    quote:


    Im fairly new to SQL Server but wish to create an application in VB (6.0) with a small SQL Server DB back end. Is this possible and easy to do?


    welcome back

    Getting a basic app skeleton using VB6 isn't really difficult.

    I think depending on your VB edition, you can choose from File-> New project the entry 'Data project'. VB add automatically references to ADO and to ADO controls. That's a basic start, but using ADO with VB is very well documented.

    However, be prepared to hand code more than say in Access.

    And the reporting engine in VB isn't by far that brilliant as Access Report Generator.

    And, as always, if you got any questions, come back and ask.

    Frank

    http://www.insidesql.de


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • quote:


    Cheers Frank......Basically the VB app is going to be a UI for the database.....does this make a difference to any methods ill need?


    Nope, that's the main purposes and strength of VB compared to VC++

    Frank

    http://www.insidesql.de

    Edited by - Frank Kalis on 10/20/2003 06:53:29 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hai Andrew,

    You can connect from VB to SQL Server is the following ways:

    1. Using ADO's

    2. Using SQL-DMO

    I'm giving a sample code related to ADO's

    Code:

    -----

    Const gCnnStr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=" & <DataBaseName> & ";Data Source=" & <ServerName>

    Dim AdoRs As New ADODB.Recordset

    Dim AdoCn As New ADODB.Connection

    'Connection establishment.

    With AdoCn

    If .State = adStateOpen Then .Close

    .CursorLocation = adUseClient

    .Open gCnnStr

    End With

    'Note: In the above connection string provide the Database Name, Server Name.

    The above code is simplest way to connect SQL server using VB 6.0

    If you have queries, ask me.

    Bye...!

  • hi!

    concerning the example: don't forget to use "tools/references" to add the ADO interfaces to your project (MDAC - available from microsoft as "MDAC_TYP.exe" in thousands of variants and installed by a whole bunch of programs silently in equally a thousand versions).

    make sure you choose a version that will exist on your clients, otherwise your EXE will fail (this is all about COM). as a baseline, i'd suggest using "ActiveX Data Object Library 2.5" (may don't be the exact wording), a version below 2.5 shouldn't be used anyway, just too old.

    best regards,

    chris.

  • Thanks guys..Im sure ill come back very soon for some more advice!

    Cheers

    quote:


    hi!

    concerning the example: don't forget to use "tools/references" to add the ADO interfaces to your project (MDAC - available from microsoft as "MDAC_TYP.exe" in thousands of variants and installed by a whole bunch of programs silently in equally a thousand versions).

    make sure you choose a version that will exist on your clients, otherwise your EXE will fail (this is all about COM). as a baseline, i'd suggest using "ActiveX Data Object Library 2.5" (may don't be the exact wording), a version below 2.5 shouldn't be used anyway, just too old.

    best regards,

    chris.


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • Eagles fly. Turkeys skydive.

  • Only skydivers know why birds sing.........

    quote:


    Eagles fly. Turkeys skydive.


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • Did you reference Microsoft ActiveX DataObjects in your project?

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Its fine now.........just a stupid mistake

    Cheers Frank

    quote:


    Did you reference Microsoft ActiveX DataObjects in your project?

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!


    If riding in a plane is flying, then riding in a boat must be swimming. To experience the element, get out of the vehicle. Skydive!

  • quote:


    Eagles fly. Turkeys skydive.


    Yeh. It's hard to fly like an Eagle when you work with Turkeys.

    Edited by - davidburrows on 11/11/2003 07:11:16 AM

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply