help with BindingSources

I need some help with BindingSources (in C#).

This is what I'm working on:

From the C# tutorial at Programmer's Heaven (

private void btnLoadData_Click(object sender, System.EventArgs e)
string connectionString = "server=P-III; database=programmersheaven; uid=sa; pwd=;";
SqlConnection conn = new SqlConnection (connectionString);
string cmdString = "SELECT * FROM article";
SqlDataAdapter dataAdapter = new SqlDataAdapter (cmdString, conn);
DataSet ds = new DataSet ();
dataAdapter.Fill (ds, "article");
dgDetails.SetDataBinding (ds, "article");

When I try to compile this, I get the following error: "The name 'dgDetails' does not exist in the current context".

I have just been told that dgDetails is a BindingSource. I'm a newbie, so I'm not familiar with BindingSources.

Could you tell me what I need to include in my code to get the compiler to recognize the dgDetails BindingSource and compile my app?


  • Just above the block of code you posted the tutorial states: "First of all add a data grid control and a button to your form using the Visual Studio toolbox. We have set the Name property of the data grid to 'dgDetails' and its CaptionText property to 'ProgrammersHeaven Database'."

    dgDetails is the ID of the datagrid control.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion