CF to load&insert image datatype into SQL Server 2005?

please..

can you help me to load & insert image into SQL VB.net sample code will be great.

thx b4

and another thing, how can we make an on the fly events such as onclick of a button




Answer this question

CF to load&insert image datatype into SQL Server 2005?

  • SKS72

  • SokSa.Icy

    Simply do this with existing row; rest of the code remains unchanged:

    myRow("img") = MyData



  • ThE ViKinG

    thanks Ilya for your reply..

    but I decided to use a parameter from querystring to do the update



  • Mark Macumber

    thanks Ilya, but i found another link

    this is how I insert

    Dim fs As New FileStream _

    (OpenFileDialog1.FileName, FileMode.OpenOrCreate, _

    FileAccess.Read)

    Dim MyData(fs.Length) As Byte

    fs.Read(MyData, 0, fs.Length)

    fs.Close()

    con.Open()

    Dim da As New SqlDataAdapter _

    ("select * from detailImg", con)

    Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)

    da.MissingSchemaAction = MissingSchemaAction.AddWithKey

    da.Fill(ds, "img")

    Dim myRow As DataRow

    myRow = ds.Tables("img").NewRow()

    myRow("img") = MyData

    ds.Tables("detailimg").Rows.Add(myRow)

    da.Update(ds, "detailimg")

    fs = Nothing

    MyCB = Nothing

    ds = Nothing

    da = Nothing

    con.Close()

    con = Nothing

    but I dont know how to update a field, can you help me one more time many thanks



  • CF to load&insert image datatype into SQL Server 2005?