Posted on 2006-03-29
Medium Priority
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
  • 2
LVL 34

Accepted Solution

Brian Crowe earned 1000 total points
ID: 16326096
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

ID: 16327725
Is this vb6?
LVL 34

Expert Comment

by:Brian Crowe
ID: 16329780
nope...vb.net.  You did post this question in a VB.Net Topic Area :-)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

839 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