0
How to create a row table in c#?
3 Respostas
0
What kind of table ? a datatable, treeview, datagrid ? winforms or wpf.
0
a datatable
0
you can use Rows.Add
DataRow newCustomersRow = dataSet1.Tables["Customers"].NewRow();
newCustomersRow["CustomerID"] = "ALFKI";
newCustomersRow["CompanyName"] = "Alfreds Futterkiste";
dataSet1.Tables["Customers"].Rows.Add(newCustomersRow);
https://msdn.microsoft.com/en-us/library/5ycd1034.aspx
or use INSERT INTO
SqlConnection and SqlCommand with a SqlCommandText.
System.Data.SqlClient.SqlConnection sqlConnection1 =
new System.Data.SqlClient.SqlConnection("YOUR CONNECTION STRING");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "INSERT Region (RegionID, RegionDescription) VALUES (5, 'NorthWestern')";
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
cmd.ExecuteNonQuery();
sqlConnection1.Close();
https://msdn.microsoft.com/en-us/library/ms233812.aspx