Jump to content
N3lson

[Resolvido] Report Viewer (sem Dataset)

Recommended Posts

N3lson

Boas gostaria de saber se é possível criar um report Viewer com Dataread sem o auxilio de um Dataset

Pois teria de colocar diversos campos provenientes de diversas tabelas.

Obrigado


You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Share this post


Link to post
Share on other sites
N3lson

Boas podem fechar este post, já consegui efectuar o que pretendia:

Para quem se deparar com este problema (tive de usar Dataset) mas personalizei o Fill.


You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Share this post


Link to post
Share on other sites
sergiogomes19

Boas. Podias dar algum exemplo da forma como usaste o Fill?

Obrigado

Share this post


Link to post
Share on other sites
N3lson

Criei o Dataset Normal com o nome Dataset com as tabelas pretendidas e afins

Depois no Windows Form


private void FormReportOrdem_Load(object sender, EventArgs e)
	{
		string query = " SELECT * FROM ord_trabalho " +
					   " INNER JOIN maquina " +
					   " ON ord_trabalho.maquina = maquina.maquina " +
					   " INNER JOIN tecnicos ON ord_trabalho.operador = tecnicos.tecnico " +
					   " WHERE ord_trabalho.id = @id";

		cmd = new MySqlCommand(query, con.liga());
		con.abre();
		cmd.Prepare();
		cmd.Parameters.AddWithValue("@id", this.textMaquina.Text);

		da = new MySqlDataAdapter(cmd);

		DataSet ds = new DataSet();

		da.Fill(ds);

		reportViewer1.LocalReport.DataSources.Clear();

		reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet", ds.Tables[0]));
		//this.reportViewer1.ConsumeContainerWhiteSpace = true;
		this.reportViewer1.RefreshReport();
}

Mantive o nome de dataset mas apenas acrescentei o WHERE xxxx

Edited by apocsantos

You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.