connecting to sql server with vb

  • I'm using vb.net standard edition to make an application that connects with a sql server database that resides on my local computer at home. I'm doing this to force myself to learn. I've been told that you can't connect using the tools (it says that with this edition you can only use access, or sqlserver desktop engine)  but you can with ado.net within the vb code. When and where do you connect - In each of the forms load event or just once in a separate module. Also when I look at the properties of the data control, specifically the connection property, it doesn't list sql server only access fox pro, ect ending with text. And finally if I'm writing code to connect, will the right fields appear in the bound controlls in the data fields property so I can set them? I pretty lost right now so any help would be a godsend. Thanks -Chris_  Oh, I just remembered another question - how do you know what protocal to use, ado or odbc or ole db?
  • Hi Chris.  You should go to http://www.asp.net and download one of the starter kits.  They have SQL Server databases included and you can learn several different ways of connecting from them.  For a list of connections strings, you can look at http://www.connectionstrings.com .  They have a list for .NET.

    Derrick Leggett
    Mean Old DBA
    When life gives you a lemon, fire the DBA.

  • Hey Chris

    VB.Net I'm not to familiar with (I use C#), but the .Net data objects are the same. Some tips to help you on your way:

    • To access SQL Server you will want to use the ADO.Net SQL Server provider. It's optimised for SQL Server, and will work easier and better than the generic ADO.Net Data providers
    • Windows / ADO / ADO.Net use Connection Pooling, so you should open a database connections only when needed. ALWAYS remember to close the connection. This frees up resources in your app, and on SQL Server. Connection Pooling will ensure that this is actually better for your app and SQL Server than leaving the connection open the entire time.

    I've found the quickest way to get on top of a new technology is to read a "dummies guide". They're cheap, take only a few hours to read cover to cover, and will give you a pretty good foundation on how to do the basics. From there there's always the provided documentation, user forums (like this), google and more books.

    Good luck!


    Julian Kuiters
    juliankuiters.id.au

Viewing 3 posts - 1 through 2 (of 2 total)

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