megatronixs
Member
- Joined
- Jan 15, 2018
- Messages
- 11
- Programming Experience
- Beginner
Hi all,
I'm trying to look for info on how to create C# windows forms with reports. there are plenty of info on how to create a report from scratch, but I could only find the ones that you define the data source from some drop down boxes and you need to set the connection etc.
I come from Ms Access databases and there creating a report is in a way more easy as the report you create is based on the same database. Initially when I started with adding datagridview to the windows forms, I had the same thing that needed to add the dataconnection (selecting database and then add it to the datagridview)
I managed to find how to create a data connection via code and it easier to manipulate. Is this possible to do this with the windows forms reports?
like here in this code example:
I'm looking for a starting point to be able to develop my skills further
Greetings
I'm trying to look for info on how to create C# windows forms with reports. there are plenty of info on how to create a report from scratch, but I could only find the ones that you define the data source from some drop down boxes and you need to set the connection etc.
I come from Ms Access databases and there creating a report is in a way more easy as the report you create is based on the same database. Initially when I started with adding datagridview to the windows forms, I had the same thing that needed to add the dataconnection (selecting database and then add it to the datagridview)
I managed to find how to create a data connection via code and it easier to manipulate. Is this possible to do this with the windows forms reports?
like here in this code example:
C#:
//-- new connection will be created
private OleDbConnection connection = new OleDbConnection();
public DataForm()
{
InitializeComponent();
//-- database location
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\FeGrand\Shareddata\Tools\Feedback\Feedback.accdb";
private void btn_search_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string temp = PrepairWhereToQuery();
string query = "SELECT * FROM tbl_main_data WHERE " + temp;
command.CommandText = query;
OleDbDataAdapter da = new OleDbDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
dgr_data.DataSource = dt;
//-- rename headers
dgr_data.Columns[0].HeaderText = "Record Nr";
dgr_data.Columns[1].HeaderText = "Area";
dgr_data.Columns[2].HeaderText = "TL/Manager/Head";
dgr_data.Columns[3].HeaderText = "Coach";
dgr_data.Columns[4].HeaderText = "Type of meeting";
dgr_data.Columns[5].HeaderText = "Date";
dgr_data.Columns[6].HeaderText = "Advantages";
dgr_data.Columns[7].HeaderText = "Disadvantages";
dgr_data.Columns[8].HeaderText = "Other Comments";
//-- hide headers if necesary
//this.dgr_data.Columns["record_id"].Visible = false;
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
connection.Close();
}
}
I'm looking for a starting point to be able to develop my skills further
Greetings