Hello everyone, can anybody tell me the best way to save richtext data into a sql server database and then retrieve the data. I have the code below to save data but I am running into an error and if I get it fixed, I still don't know if the rest of it will work. The problem occurs when dimming the filestream object. Thanks for the help.
Dim fs As New FileStream()
Me.rtfTest.SaveFile(fs, RichTextBoxStreamType.RichText)
Dim ba(fs.Length) As Byte
fs.Read(ba, 0, fs.Length)
fs.Close()
Dim ado As New ADO()
ado.strSQL = "Select imgText From zTestRichText"
ado.CreateAdapter()
ado.UseCommandBuilder()
ado.CreateDataSet()
ado.objDA.MissingSchemaAction = MissingSchemaAction.AddWithKey
fs.Close()
ado.OpenConnection()
ado.objDA.Fill(ado.objDS, "MyImages")
Dim myRow As DataRow
myRow = ado.objDS.Tables("MyImages").NewRow()
myRow("imgText") = ba
ado.objDS.Tables("MyImages").Rows.Add(myRow)
ado.objDA.Update(ado.objDS, "MyImages")
ado.CloseConnection()
fs = Nothing
ado = Nothing
MsgBox("Save Complete")
Randy Belcher
AFG Industries, Inc.