当前位置:编程学习 > C#/ASP.NET >>

如何把richtextbox中的内容保存到sqlserver数据库中,请给出代码(vb.net)

如何把richtextbox中的内容保存到sqlserver数据库中,请给出代码(vb.net) --------------------编程问答--------------------

Dim intImageSize As Int64
    Dim strImageType As String
    Dim ImageStream As Stream

    Gets the Size of the Image
    intImageSize = PersonImage.PostedFile.ContentLength

    Gets the Image Type
    strImageType = PersonImage.PostedFile.ContentType

    Reads the Image
    ImageStream = PersonImage.PostedFile.InputStream

    Dim ImageContent(intImageSize) As Byte
    Dim intStatus As Integer
    intStatus = ImageStream.Read(ImageContent, 0, intImageSize)

    Create Instance of Connection and Command Object
    Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    Dim myCommand As New SqlCommand("sp_person_isp", myConnection)

    Mark the Command as a SPROC
    myCommand.CommandType = CommandType.StoredProcedure

    Add Parameters to SPROC
    Dim prmPersonImage As New SqlParameter("@PersonImage", SqlDbType.Image)
    prmPersonImage.Value = ImageContent
    myCommand.Parameters.Add(prmPersonImage)

    Dim prmPersonImageType As New SqlParameter("@PersonImageType", SqlDbType.VarChar, 255)
    prmPersonImageType.Value = strImageType
    myCommand.Parameters.Add(prmPersonImageType)

    Try
        myConnection.Open()
        myCommand.ExecuteNonQuery()
        myConnection.Close()
        Response.Write("New person successfully added!")
    Catch SQLexc As SqlException
        Response.Write("Insert Failed. Error Details are: " & SQLexc.ToString())
    End Try
--------------------编程问答-------------------- 呵呵,楼主说话是真不客气. --------------------编程问答-------------------- 学习学习
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,