0

How to create a row table in c#?

27th Aug 2017, 10:25 AM
M Arun Kumar
M Arun Kumar - avatar
3 Respostas
0
What kind of table ? a datatable, treeview, datagrid ? winforms or wpf.
27th Aug 2017, 10:32 AM
sneeze
sneeze - avatar
0
a datatable
27th Aug 2017, 4:01 PM
M Arun Kumar
M Arun Kumar - avatar
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
27th Aug 2017, 6:56 PM
sneeze
sneeze - avatar