views:

278

answers:

2

I think it's kind of noob question but I'm new to SQL Server in .NET and I've already lost several hours on this...

I started new project, inserted DataGridView on empty form and as Data Source I chose Add->Database and I created new SQL Server Database File. I called it db.mdf. Now I get DataSet named dbDataset and BindingSource named dbDataSetBindingSource. I also added LINQ to SQL Classes to my project and dragged my table (where I added some rows before) to my .dbml. Next I doubleclicked my dbDataset and in designer dragged and dropped the same table.

I hope you have an image now ;). The thing is that when I run program, nothing shows in DataGridView. I know that I can do

dbDataClassesDataContext db = new dbDataClassesDataContext();
var records= from rec in db.MyTable select rec;
dataGridView1.DataSource = records;

And it works perfect. But I believe that dbDataSet and dbDataSetBindingSource should work too... How to use them just to show data in DataGridView?

+1  A: 

OMG, found it... For any others with this problem in future. Click on BindingSource in designer and in properties choose table in DataMember.

Episodex
A: 

some useful tips about datagridview

http://csharp.net-informations.com/datagridview/csharp-datagridview-tutorial.htm

gever

geveruk