Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving data
Message
De
14/08/2003 14:28:36
 
 
À
14/08/2003 13:43:42
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00819761
Message ID:
00820273
Vues:
14
Hey Viv, thanks for getting back to me. What I am actually doing is trying to save richtext information to a sql server database. I have the save working now using the memorystream, but I am having problems loading the information into the richtext box. Below is the load code with the error. I will post the save code at the bottom in case someone wants to use it.
        Dim ado As ADO = New ADO()

        ado.strSQL = "Select keyID, imgText From zTestRichText Where keyID = 1"
        ado.RetrieveData(ado.objDS, "MyImages")

        Dim myRow As DataRow
        myRow = ado.objDS.Tables("MyImages").Rows(0)

        Dim MyData() As Byte
        MyData = myRow("imgText")
        Dim K As Long
        K = UBound(MyData)

        Dim ms As New MemoryStream(K - 1)

        ms.Write(MyData, 0, K)

        ' Error occurs on Next Line :Additional information: Offset and
        ' length were out of bounds for the array or count is greater than 
        ' the number of elements from index to the end of the source 
        ' collection.
        Me.rtfTest.LoadFile(ms, RichTextBoxStreamType.RichText)

        ms.Close()

        ms = Nothing
        ado = Nothing

        MsgBox("Load Complete")
Here is the save code, this works.
        Dim ms As New MemoryStream()

        Me.rtfTest.SaveFile(ms, RichTextBoxStreamType.RichText)
        Dim ba(ms.Length) As Byte

        ms.Read(ba, 0, ms.Length)
        ms.Close()
        ms = Nothing

        Dim ado As New ADO()

        ado.strSQL = "Select keyID, imgText From zTestRichText Where keyID = 1"
        ado.CreateAdapter()
        ado.UseCommandBuilder()
        ado.CreateDataSet()

        ado.OpenConnection()
        ado.objDA.Fill(ado.objDS, "MyImages")

        ' A primary key must be set to use the command builder object to update tables.
        '*********
        Dim dt As DataTable = ado.objDS.Tables("MyImages")
        Dim pk As DataColumn = dt.Columns("keyID")

        dt.PrimaryKey = New DataColumn() {pk}
        '**********
        ' End setting up a primary on the dataset.

        ado.objDS.Tables("MyImages").Rows(0).Item("imgText") = ba
        ado.objDA.Update(ado.objDS, "MyImages")
        ado.CloseConnection()

        ado = Nothing

        MsgBox("Save Complete")
Randy Belcher
AFG Industries, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform