0

Can someone provide sample code on how to create and fill a DataTable with the table schema and data from a mySQL database?

I found examples where you set up columns and other information programmatically. But i wanted to know if there a way to "sync" the schema in the database table to the DataTable object so you don't have to set up the columns, or keys manually.
Thanks

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Sailor_Jerry
0

Yeah I ended up doing this:

DbCommand command = CreateCommand(com);
			DbDataAdapter adapter = new MySqlDataAdapter();
			adapter.SelectCommand = command;
			DataTable dataTable = new DataTable();

			try
			{
				adapter.Fill(dataTable);
				if(dataTable.Rows.Count > 0)
				{
					return dataTable;
				}
			}
			catch(Exception)
			{
			}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.