c# - Display SQL Server table in DataGridView -
I think this is a type of noob question, but I am new to SQL Server in .NET and I have previously It has lost several hours on this ...
I started a new project, inserted DataGrid view on the empty form and as a data source, I chose Add-> Database and I created a new SQL Server database file . I called it DB.MDF. Now I get a binding source named DBDataset dataset and dbDataSetBindingSource. I added LINQ to SQL class in my project and pulled my table (where I added some lines before) in my .dbml. After this I pulled my DB dataset and pulled it into the designer and removed the same table.
I hope you have an image now;) The thing is that when I run the program, the datagroup does not show anything in the scene. I know that I can
dbDataClassesDataContext db = new dbDataClassesDataContext (); Var Record = db.MyTable from Rec in RE; DataGridView1.DataSource = Record;
And it works right. But I believe dbDataSet and dbDataSetBindingSource should also work ... How to use them to show data in DataGridView?
OMG, found this ... for any other with this problem in the future. Click the binding source in the designer and select the table in properties in DataMember .
Comments
Post a Comment