Click here to Skip to main content
15,921,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiii,
i have got outputs in a program. now i have to tabulate them in visual studio.
i am struck with how to do it.
please help....
i am a begginer..
i have been googling but not found an easy way to understand...

thanks in advance
Posted

1 solution

1) Create a new windows application project
2) Drag a Datagrid view in Form
3) Create a simple MySql Table
4) Try the below code

private DataTable getTable()
{
// Database code
MySqlCommand command = GetDatabaseConnection().CreateCommand();
MySqlDataAdapter mda = new MySqlDataAdapter();
DataTable dt = new DataTable();

command.CommandType = CommandType.Text;
string sqlStatement = "select * from table";
command.CommandText = sqlStatement;

mda.SelectCommand = command;
mda.SelectCommand.Connection = GetDatabaseConnection();
mda.Fill(dt);
//Dispose the command object
command.Dispose();

return dt;
}

//Front end form code

private void Form_Load(object sender, EventArgs e)
{
   DataTable dTable = new Datatable;
   dTable = datagridview1.Datasource;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900