Jump to content

[vb.net 2003] Crystal reports...


rui_fernandes
 Share

Recommended Posts

rui_fernandes

boas...

estou a criar um relatorio onde as tabela onde vai vai ser buscado os dados para o preencher sao relacionadas...

ponho os campos que keru que sejam mostrados, que vao ser alguns dependendo se um campo for igual a um determinado valor...

Dim rpt As New CrystalReport1
        Dim coneccaoBD As OleDbConnection
        Dim da As New OleDbDataAdapter

        Dim cod_servico As Integer = 19

        Dim ds As New Dataset1
        Dim caminho As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & Application.StartupPath.ToString & "\gestao.mdb"
        coneccaoBD = New OleDbConnection(caminho)
        coneccaoBD.Open()
        Dim cmd As OleDbCommand = New OleDbCommand
        Try

            cmd.Connection = coneccaoBD
            cmd.CommandText = "SELECT obs,alinea FROM detalhe_servico WHERE cod_servico=" & cod_servico

            cmd.CommandType = CommandType.Text
            da.SelectCommand = cmd
            da.Fill(ds, "Customers")
            rpt.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rpt

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

tem de selecionar todos registos do campo OBS e ALINEA onde cod_servico=19....

mas preenche-me com todos os registos desses campos... ?

alguem sabe se estou a fazer alguma coisa mal???????? ?

agradecia a ajuda.

CUMPS.

Rui Fernandes

Link to comment
Share on other sites

Boas

E estranho devia de dar, de certeza que a tabela  detalhe_servico tem linhas com cod_servico  <> 19?

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Tens que alterar o sql para fazer join das tabelas detalhe_servico e servico, assim já deve dar.

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Retira as tabelas servico, tipo_dia , viagem e viatura do report e já deve dar.

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

rui_fernandes

nao pode ser porque vou ter de utilizar essas tabela tds, estao relacionadas e vai ser para ir buscar dados de todas..

mas explica-me uma coisa, preenche-se o dataset, e o que é que faz exactamente isto???

 Dim rpt As New CrystalReport1
            rpt.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rpt

cUMPS.

Rui Fernandes

Link to comment
Share on other sites

rui_fernandes

problema resolvido.estava a ir buscar os dados a Base de dados, nao ao dataset que estava a preencher com os dados que realmente keria.

abrigado.

Rui Fernandes

Link to comment
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
 Share

×
×
  • 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.