我希望有一種方法來動態地在Visual Studio中創建一個數據集(我使用的是C#) 我知道你可以創建一個點擊和拖動的方式,但希望有一種方法來動態創建一個因爲我需要將數據放入從任何數據庫和任何表格以及任何列中收集的報告中(我有一個程序可以連接到任何mysql或sql數據庫,並顯示任何表和任何列)。如何以編程方式在c#中創建數據集?
現在我需要把它放在報告中。 但首先是一個數據集。
DataTable table1 = new DataTable("patients");
table1.Columns.Add("name");
table1.Columns.Add("id");
table1.Rows.Add("sam", 1);
table1.Rows.Add("mark", 2);
DataTable table2 = new DataTable("medications");
table2.Columns.Add("id");
table2.Columns.Add("medication");
table2.Rows.Add(1, "atenolol");
table2.Rows.Add(2, "amoxicillin");
// Create a DataSet and put both tables in it.
DataSet set = new DataSet("office");
set.Tables.Add(table1);
set.Tables.Add(table2);
// TODO: This line of code loads data into the 'SwimkidzDataSet.Branches' table.
// You can move, or remove it, as needed.
this.BranchesTableAdapter.Fill(this.manuallyCreatedDataset.Branches);
試過,但沒有機會,將工作
this.BranchesTableAdapter.Fill(set);
this.reportViewer1.RefreshReport();
我猜「動態」意味着代碼?刪除VS2010標籤並添加一種語言。 –
我改變了它,但問題是,visual studio可以拿起在內存中製作的數據集。這就是爲什麼我有vs2010標籤,因爲在我的大腦中,我看到病人必須創建一個將其添加到我的vs項目中的標籤? – mrbunyrabit
該死的......一個全新的插件去了解...... 因爲我試過這個,不認爲它會工作(添加它) – mrbunyrabit