Results 1 to 6 of 6

Thread: How I can start application with SQL

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    185

    How I can start application with SQL

    I am working with ".mdb" file & DAO successfully (VB6).
    But for 2 problem I have to work with SQL I think.
    _1. data security
    _2. using more PC with same database.
    _and also 3. using large database

    Now I cannot start programing with SQL(SQL 2000) from VB6.
    I need ......
    __(1) code to store a data (a row) to SQL database
    __(2) code view data (a row) from SQL database
    using any Connection method & Provider, what is best for me for Data security & using lan networking.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How I can start application with SQL

    Welcome to the forum!

    Here's a link showing a connection routine.

    You should use ADO with MS SQL.

    http://www.vbforums.com/showthread.p...39#post1804439

    Also - there are threads at the top of the DB forum here that have tutorials and other info on SQL - but still, feel free to ask!

    btw - in our shop we never use Bound controls and always use STORED PROCEDURES...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How I can start application with SQL

    Quote Originally Posted by r_amin
    I am working with ".mdb" file & DAO successfully (VB6).
    But for 2 problem I have to work with SQL I think.
    _1. data security
    _2. using more PC with same database.
    _and also 3. using large database

    Now I cannot start programing with SQL(SQL 2000) from VB6.
    I need ......
    __(1) code to store a data (a row) to SQL database
    __(2) code view data (a row) from SQL database
    using any Connection method & Provider, what is best for me for Data security & using lan networking.
    If you know how to insert and fetch records using DAO then you would do just fine in SQL since they use the same SQL...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    185

    Re: How I can start application with SQL

    Quote Originally Posted by dee-u
    If you know how to insert and fetch records using DAO then you would do just fine in SQL since they use the same SQL...
    you mean, I can use DAO with SQL?

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How I can start application with SQL

    First - you should remove your e-mail address from your other thread - it will be picked up by bots and you will get spammed!

    Second - you should use ADO to connect to MS SQL server. I gave you a link with VB code for a connection - but here it is anyway:

    Code:
        If strDriver = "" Then
            strDriver = "SQLOLEDB"
        End If
        
        'Create a connection to the database
        Set gCn = New ADODB.Connection
        
        gCn.Provider = strDriver
        gCn.Properties("Data Source").Value = strServer
        gCn.Properties("Initial Catalog").Value = strDatabase
        If gstrUser <> "" Then
            gCn.Properties("User Id").Value = gstrUser
            gCn.Properties("Password").Value = gstrPassWord
        Else
            gCn.Properties("Integrated Security").Value = "SSPI"
        End If
        
        gCn.CommandTimeout = 300
        gCn.Open
        
        'Check the connection state
        If gCn.State = adStateOpen Then
            EstablishConnection = True
        Else
            EstablishConnection = False
        End If
    This will establish a connection to the DB.

    Third - use the SEARCH feature of this forum - and search for "GCN" - this is my global connection variable. You will find dozens of threads with all kinds of examples of working with SQL from VB.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How I can start application with SQL

    Quote Originally Posted by r_amin
    you mean, I can use DAO with SQL?
    No, as Szlamany suggested you should use ADO. What I meant was the DML's, the AddNew, etc are basically the same or with very minimal difference...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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