How to save images and formated text with rich text box in SQL and show on crystal report VB.NET
I try below code to insert images in rich text box.
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim ff As New OpenFileDialog
ff.Filter = "Image Files|*.gif;*.jpg;*.png;*.bmp"
ff.ShowDialog()
Dim img As System.Drawing.Image = System.Drawing.Image.FromFile(ff.FileName)
Dim orgData = Clipboard.GetDataObject
Clipboard.SetImage(img)
Me.rtb.Paste()
Clipboard.SetDataObject(orgData)
End Sub
And here i insert it into into SQL
Dim sname As Integer = Integer.Parse(txt1.Text)
Dim sfname As Integer = 2
Dim scnic As String = rtb.rtf
query &= "INSERT INTO tencmpC1 (qnumber,topic,Umcq)"
query &= "VALUES (@qnumber, @topic,@Umcq )"
Using conn As New SqlConnection(strConn)
Using comm As New SqlCommand()
With comm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = query
.Parameters.AddWithValue("@qnumber", sname)
.Parameters.AddWithValue("@topic", sfname)
.Parameters.AddWithValue("@Umcq", scnic)
conn.Open()
comm.ExecuteNonQuery()
txt10.Text = "question saved "
End With
End Using
I am using nvarchar(max) as "datatype to SQL field" for RTB text. I am using textformate for crystal report "crRTFText". Please guide me what and where i have to do changes? Thanks in advance