Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    7

    [VB 2010] Report Di un Database con Immagini

    Premetto di non essere un esperto di Visual Basic anzi ho appena iniziato perchè sto facendo lo stage in una ditta...Comunque ho creato un database con sql di CD con titolo artista durata e Copertina tramite Vb sono riuscito a metterlo in un Datagridview per visualizzare tutte le copertine e ho creato dei comandi per aggiungere,eliminare o modificare record...ora mi è stato chiesto di fare un report dove vengano visualizzate anche le immagini qui mi sono bloccato ho provato e riprovato con Reportviewer ma proprio non riesco perchè sinceramente non ho mai fatto record praticamente riesco a far visualizzare tutti i campi di testo ma non le immagini...girando su internet e per i forum ho provato con una cosa del genere Fields!Immagine.Value ma non mi funziona mi da un errore su Fields!...Qualcuno può aiutarmi? Grazie in anticipo

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    7
    Dato che non vedo molte risposte voglio inserire l'intero codice del mio programma giusto per dare un'idea...vorrei sapere se arrivato a questo punto possofare un report con tutti i campi del mio database...
    codice:
    Imports System.Data.SqlClient
    Public Class Form1
      Dim Mycn As New SqlConnection
      Dim MyCmd As New SqlCommand
      Dim myAdapter As New SqlDataAdapter
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: questa riga di codice carica i dati nella tabella 'CDDataSet.CD'. È possibile spostarla o rimuoverla se necessario.
        Me.CDTableAdapter.Fill(Me.CDDataSet.CD)
        Mycn.ConnectionString = "Data Source=svr01;Database=CD;User ID=sa;Password=123"
        Dim s As String
        Dim a As Integer = (DataGridView1.RowCount - 2)
        Try
          Mycn.Open()
        Catch ex As Exception
          MsgBox("Non sono riuscito a connettermi")
        End Try
        MyCmd.Connection = Mycn
        For i As Integer = 0 To a
          DataGridView1.Rows(i).Height = 60
          s = ("C:\Documents and Settings\simone\Documenti\Immagini\Giovanni CD\" & DataGridView1.Rows(i).Cells(4).Value)
          Dim bm As New Bitmap(s)
          Me.DataGridView1.Rows(i).Cells(5).Value = bm
          MyCmd.CommandText = ("UPDATE CD SET Immagine = '" & s & "' WHERE Nome = '" & DataGridView1.Rows(i).Cells(0).Value & "'")
          MyCmd.ExecuteNonQuery()
        Next
      End Sub
    
      Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim MyCmd As New SqlCommand
        Dim nom, art, cop As String
        Dim dur, bra As Integer
        nom = InputBox("Inserisci nome", "Input box")
        art = InputBox("Inserisci artista", "Input box")
        bra = InputBox("Inserisci n° brani", "Input box")
        dur = InputBox("Inserisci durata cd", "Input box")
        cop = InputBox("inserisci nome copertina", "input box") & ".jpg"
        MyCmd.Connection = Mycn
        MyCmd.CommandText = "INSERT INTO CD(Nome,Artista,Brani,Durata,Copertina) VALUES('" & nom & "','" & art & "','" & bra & "','" & dur & "','" & cop & "')"
        MyCmd.ExecuteNonQuery()
      End Sub
    
      Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim MyCmd As New SqlCommand
        MyCmd.Connection = Mycn
        Dim o As String
        o = InputBox("Inserisci Cd da eliminare", "Input Box")
        MyCmd.CommandText = ("DELETE FROM CD WHERE Nome= '" & o & "'")
        MyCmd.ExecuteNonQuery()
      End Sub
    
      Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim MyCmd As New SqlCommand
        MyCmd.Connection = Mycn
        Dim o As String
        Dim nom, art, cop As String
        Dim dur, bra, i As Integer
        o = InputBox("Inserisci Cd da modificare", "Input Box")
        i = InputBox("Per modificare interamente il record digitare 0 per modificare solo un campo del record digitare 1", "input box")
        If i = 0 Then
          nom = InputBox("Inserisci nome", "Input box")
          art = InputBox("Inserisci artista", "Input box")
          bra = InputBox("Inserisci n° brani", "Input box")
          dur = InputBox("Inserisci durata cd", "Input box")
          cop = InputBox("inserisci nome copertina", "input box") & ".jpg"
          MyCmd.CommandText = ("UPDATE CD SET Nome = '" & nom & "',Artista = '" & art & "',Durata = '" & dur & "',Brani= '" & bra & "',Copertina= '" & cop & "' WHERE Nome = '" & o & "'")
          MyCmd.ExecuteNonQuery()
        Else
          Dim s As String
          s = InputBox("Inserisci campo da modificare", "Input Box")
          Select Case s
            Case "Nome"
              nom = InputBox("Inserisci nome", "Input box")
              MyCmd.CommandText = ("UPDATE CD SET Nome = '" & nom & "' WHERE Nome = '" & o & "'")
              MyCmd.ExecuteNonQuery()
            Case "Artista"
              art = InputBox("Inserisci artista", "Input box")
              MyCmd.CommandText = ("UPDATE CD SET Artista = '" & art & "' WHERE Nome = '" & o & "'")
              MyCmd.ExecuteNonQuery()
            Case "Brani"
              bra = InputBox("Inserisci n° brani", "Input box")
              MyCmd.CommandText = ("UPDATE CD SET Brani = '" & bra & "' WHERE Nome = '" & o & "'")
              MyCmd.ExecuteNonQuery()
            Case "Durata"
              dur = InputBox("Inserisci durata cd", "Input box")
              MyCmd.CommandText = ("UPDATE CD SET Durata = '" & dur & "' WHERE Nome = '" & o & "'")
              MyCmd.ExecuteNonQuery()
            Case "Copertina"
              cop = InputBox("inserisci nome copertina", "input box") & ".jpg"
              MyCmd.CommandText = ("UPDATE CD SET Copertina = '" & cop & "' WHERE Nome = '" & o & "'")
              MyCmd.ExecuteNonQuery()
          End Select
        End If
      End Sub
    
      Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        'TODO: questa riga di codice carica i dati nella tabella 'CDDataSet.CD'. È possibile spostarla o rimuoverla se necessario.
        Me.CDTableAdapter.Fill(Me.CDDataSet.CD)
        Dim s As String
        Dim a As Integer = (DataGridView1.RowCount - 2)
        MyCmd.Connection = Mycn
        For i As Integer = 0 To a
          DataGridView1.Rows(i).Height = 60
          s = ("C:\Documents and Settings\simone\Documenti\Immagini\Giovanni CD\" & DataGridView1.Rows(i).Cells(4).Value)
          Dim bm As New Bitmap(s)
          Me.DataGridView1.Rows(i).Cells(5).Value = bm
          MyCmd.CommandText = ("UPDATE CD SET Immagine = '" & s & "' WHERE Nome = '" & DataGridView1.Rows(i).Cells(0).Value & "'")
          MyCmd.ExecuteNonQuery()
        Next
      End Sub
    
      Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
        Dim SecondoForm As New Form2
        SecondoForm.Show()
      End Sub
    End Class
    Ok naturalmente Click 5 richiamo un secondo Form nel quale andranno poi le istruzioni per creare il Report...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.