Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Saving image into SQL DB via vb.net. Programmatically work but not store anything in 'table'.

$
0
0

I have some problem with my program, just figure it out by this question tittle. I have some code. No error. And it also work properly. But it's not storing anything in database. While I change into another DB. It works perfectly.

Can anyone help me. Here are my Source code

Public Sub saveGmbr(x As String, tabel As String, fieldIMG As String, fieldCode As String, valueCode As String)
        Try
            Using cmd As New SqlClient.SqlCommand("update " + tabel + " set " + fieldIMG + " = @img where " + fieldCode + "=@val;", conn)
                cmd.Parameters.Add(New SqlClient.SqlParameter("@img", SqlDbType.VarBinary)).Value = IO.File.ReadAllBytes(x)
                cmd.Parameters.Add(New SqlClient.SqlParameter("@val", SqlDbType.NVarChar)).Value = valueCode

                cmd.ExecuteNonQuery()
            End Using

            MessageBox.Show("Gambar berhasil disimpan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Peringatan1", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

I already change it in much times. This is last version which I heard work in other program. Can anyone resolve my problem, please. This problem make me crazy.


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>