Hi
I have to program in C# such that I have to add a button to the form , and
create a crystal report, by getting source
from the xml schema file(.xsd file) with two fields namely name,image.....
name is string datatype and image is of
datatype base64Binary. Now i have to add a crystal report viewer to the form
and whenthe program is run, we
should be able to load any image ,ie, by clicking the button add any image
from the disk and that image should be displayed
in the report in image column......
so wht i have to do is
-create a dataset that supports images
-create a report that support this dataset
-load data in the dataset
-use the dataset as datasource for the report and show the report in the
viewer
Then i found a code in Vb...
please change for me in c# and explain how to do...
i will paste the coding part
Code:
Private Sub btnLoadImage_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnLoadImage.Click
Dim ofdImage As New OpenFileDialog
If ofdImage.ShowDialog = DialogResult.OK Then
Try
'Create a new instance of the dataset
Dim dsImgRpt As New dsImageReport
'Create a new instance of the report
Dim m_imagereport As New rptImage
'Create a new row in the dataset
Dim dr As dsImageReport.ImageRow = _
dsImgRpt.Image.NewImageRow
'Set the various elements of the row
dr.Name = ofdImage.FileName
'fill this field with a byte array
dr.Photo = GetImageData(ofdImage.FileName)
'Add the new row to the dataset
dsImgRpt.Image.Rows.Add(dr)
'Use the dataset as datasource for the report
m_imagereport.SetDataSource(dsImgRpt)
'Show the report in the reportviewer
Me.crystalReportViewer1.ReportSource = m_imagereport
Catch ex As Exception
MessageBox.Show("Something went wrong: " & ex.Message)
End Try
End If
End Sub
Private Function GetImageData(ByVal fileName As String) As Byte()
'Method to load an image from disk and return it as a bytestream
Dim fs As System.IO.FileStream = _
New System.IO.FileStream(fileName, _
System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim br As System.IO.BinaryReader = New System.IO.BinaryReader(fs)
Return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length )))
End Function
please help me to do this..
batista