How do I write data into a DataGridView

Posted on 2008-11-10
Last Modified: 2013-11-26
I have created a database (dbsCustomer) in MS SQL Studio Express. There is a table (tblCustomers) which I want to display in VB, using a DataGridView. I am using Visual Studio 2005.

I have 3 classes in my VB.
(1)libDataAccessLayer (for reading data from the DBMS); I have added the database as a Data Source in this layer.

(2)libBusinessLayer (which gets the data from libDataAccessLayer)

(3)Display, holds a form to display the data in the DataGridView).

I just could not load anything in the DataGridView. Can anyone see if I have done anything wrong, or have I left something out?

I have attached a .doc file containing the codes that were used. There are coding for libAccessLayer, libBusinessLayer and Display; as well as the SQL statements for the database

Question by:flooz
    LVL 8

    Accepted Solution

    You have to bind your datagridview to the BindingSource:

    dgvCustomers.DataSource = bndCustomers

    Expert Comment

    Set the Datasource property on the Datagridview on the Form page and modify what you would like in the GUI editor.  In the code behind fill the datasource for the page using Fill in the Load Function.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now