Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ODBC API and Visual Basic

Options
  • 16-05-2003 6:05pm
    #1
    Registered Users Posts: 7,468 ✭✭✭


    Can somebody point me in the direction of a good VB ODBC Api tutorial or reference site? I want to be able to list the System DSN's.


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)

    Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer


    is what I was looking for, if anybody is interested :)

    <additional self-wh0ring/>
    I'm thinking of writing an article on this API for Vb 6 developers. I know ADO and DAO covers all the actual database work but there are things they don't do that this API can AFAIK, such as return all DSNs registered in Windows. So:
    1. Whats the interest in such an article?
    2. What would you, the vb community as large, like to see in such?
    3. Is there anything you think ADO or DAO should be able to do but can't?


  • Registered Users Posts: 640 ✭✭✭Kernel32


    As a professional software developer, I haven't written anything in VB6 for at least 2 years. I wonder how much new development if any is being done using VB6 these days, VB6 is pretty much legacy in the business world as far as I tell.
    So my answer would be that there wouldn't be much interest in an article like this.

    Feel free to disagree with me though!


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I'm still working with vb6 on some projects but it depends on the size of the business. A lot of smaller companies, like my customers, would have an old architecture so Vb6 is the language of choice in that case, but those days are numbered and I'm pushing for .NET more and more. Somebody has to support legacy code though.

    However I won't write it if nobody is going to read it. Thanks for the feedback Kernel32.


  • Closed Accounts Posts: 413 ✭✭sobriquet


    Funnily enough, just such a tut would be quite handy for me. I have to write some VB6 code to connect to a DB via a variety of methods, and getting my code to validate the existance of a DSN prior to making a connection is on my mental to-do pile. Go for it. Get back to me if you want help testing code etc.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by Kernel32
    As a professional software developer, I haven't written anything in VB6 for at least 2 years. I wonder how much new development if any is being done using VB6 these days, VB6 is pretty much legacy in the business world as far as I tell.

    I'd say that VB6 is no less of a legacy than COBOL is. After all, there's more VB code running in production environments than there is COBOL, and no-one really suggests that COBOL is going away any time soon.

    Having said that, I wouldnt be particularly interested in the article Phil....to be honest, I'd be more interested in having a link to whatever groovy little class/DLL you create at the end of it all. Ideally with source-code, but hey...

    jc


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I'm thinking of a How-To for a VB website I go to for such things, with of course a sample project. If its published I'll let you all know.

    The reason I'm doing this for VB6 is two-fold. Firstly, I'm actually using this code in a project. Second, I think theres enough VB6 development going on out there to warrant the article. VB6 is what I've been developing with for 5 years now and Bonkey is correct; there is still a demand there.


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Originally posted by sobriquet
    Funnily enough, just such a tut would be quite handy for me. I have to write some VB6 code to connect to a DB via a variety of methods, and getting my code to validate the existance of a DSN prior to making a connection is on my mental to-do pile.
    Not wanting to steal Evil Phil's thunder (and I'm sure he has more to show us than how to examine the registered DSNs) but if that's something you need to know how to do before this tutorial is written take a look at the HKEY_CURRENT_USER\Software\ODBC\ODBC.INI, HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI and HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI keys, which store local DSNs, system DSNs and installed drivers respectively. HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC File DSN has the information you need to track down the file DSNs as well. I don't know the ODBC API, so maybe when Evil Phil has his tutorial up I'll realise I've been making life hard for myself, but I found querying those keys to be an easy enough way to build a UI selection of DSNs.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I actually didn't know about them, you could just call RegEnumValue to list them and work from there.

    As for the tutorial, well I'll write it anyway and let you all decide for yourselves which way you prefer. It will be next week as I'm off from Wednesday 'til Sunday of this week.

    The palimenary structure of the tutorial will be:
    • How to list the System DSNs (may include File DSNs, but probably won't)
    • How to list the available drivers
    • How to retrieve catalog data on the DSNs
    • How to retrieve driver information


Advertisement