zoukankan      html  css  js  c++  java
  • Insert image type column to SQlServer

    The below is the related code ,but pls remember to clear the image column in updateCommand 's syntax,and updateparams in aspx file.

     

    If you don't clear it , the sqlcommand will reexecute it. and it'll produce a error.

     

    Public Sub UpdatePhoto(ByVal Id As Integer, ByVal PhotoFile As FileUpload)

    If (PhotoFile Is Nothing) Or (Not PhotoFile.HasFile) Then

    Return

    End If

    Using cn As New SqlConnection(GlobalVarible.ConnectionString)

    Using cmd As New SqlCommand("update StaffDemo set Image=@Image where id=@ID", cn)

    cmd.Parameters.Add("ID", Data.SqlDbType.Int).Value = Id

    cmd.Parameters.Add("@Image", Data.SqlDbType.Image).Value = PhotoFile.FileBytes

    cn.Open()

    cmd.ExecuteNonQuery()

    End Using

    End Using

    End Sub

     

     

  • 相关阅读:
    JavaScript基础学习篇
    js,html,css注释大集合
    JS中的专业术语
    BFC给我的帮助以及对hasLayout的认识
    框架
    PHP echo和print语句
    PHP变量
    PHP语法
    PHP入门
    SQLite学习网址
  • 原文地址:https://www.cnblogs.com/Excellentchen/p/1755467.html
Copyright © 2011-2022 走看看