Solved

BindingSource error

Posted on 2012-03-22
2
365 Views
Last Modified: 2012-03-22
hi,

I get a compilation error in the follwoing code.

errors:
Error      1      An object reference is required for the non-static field, method, or property 'System.Windows.Forms.BindingSource.DataMember.get'

Error      2      An object reference is required for the non-static field, method, or property 'System.Windows.Forms.BindingSource.DataSource.get'

code:
 private void Form1_Load(object sender, EventArgs e)
        {
            DBO db = new DBO();
            BindingSource.DataMember = "Sample";
            BindingSource.DataSource = db;
            this.reportViewer1.RefreshReport();

        }

How can I solve the problem?

Please help

ayha
0
Comment
Question by:ayha1999
2 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 37754631
You don't seem to have initialized your bindingsource properly :
private BindingSource binding1;
 private void Form1_Load(object sender, EventArgs e)
        {
            DBO db = new DBO();
            binding1 = new BindingSource();
            binding1.DataMember = "Sample";
            binding1.DataSource = db;
            this.reportViewer1.RefreshReport();

        }

Open in new window

0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 37754734
Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

25 Experts available now in Live!

Get 1:1 Help Now