Posted on 2006-03-29
Last Modified: 2010-04-23
How many ways can we connect to database(database connection, data adapter, dataset)? Also, you could give me a sample how to display data (from SQL2000 server) to a datagrid?  I'm a newbie .
Question by:VBdotnet2005
    LVL 34

    Accepted Solution

    dataadapter and datareader are the typical ways.

    private ds as new dataset
    private da as new sqldataadapter
    private sub load(...) handles mybase.load
       myDataGrid.datasource = ds.tables("Data")
    end sub

    private sub DefineAdapter()
       with da
          .selectcommand = new sqlcommand
          with .selectcommand
             .connection = new sqlconnection({connection string})
             .commandtext = "SELECT col1, col2, col3 FROM myTable"
          end with
          'optionally add insertcommand/updatecommand/deletecommand if you want to update your database from the app

          .acceptchangesduringfill = true
          .tablemappings.add("Table", "Data")
       end with
    end sub

    Author Comment

    Is this vb6?
    LVL 34

    Expert Comment

    by:Brian Crowe  You did post this question in a VB.Net Topic Area :-)

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now