Click here to Skip to main content
11,636,778 members (76,906 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows VB.NET .NET4 WinForm , +
'In DA_Company'
 Function Company_Save(ByVal M_Model_DA As Model.M_Company) As String
            cmd = New SqlCommand()
            cmd.CommandText = "SP_HR_Company_Insert"
            cmd.Connection = con
            cmd.CommandType = CommandType.StoredProcedure 
            cmd.Parameters.Add("@Company_Logo", SqlDbType.Image).Value = M_Model_DA.Company_Logo
            err_message = cmd.ExecuteNonQuery()
        Catch ex As Exception
            err_message = ex.ToString()
        End Try
        Return err_message
    End Function

'In BL_Company'

  Function Company_Save(ByVal M_Company_BL As Model.M_Company) As String
            DA_Company = New DataAccess.DA_Company()
            error_message = DA_Company.Company_Save(M_Company_BL)
        Catch ex As Exception
            error_message = ex.ToString()
        End Try
        Return error_message
    End Function

'In M_Company'

 Public Property Company_Logo() As Byte
            Return Me.CompanyLogo
        End Get
        Set(ByVal value As Byte)
            Me.CompanyLogo = value
        End Set
    End Property

'In Frm_Company'

  Private Sub Company_Save()
            BL_Company = New BusinessLogic.BL_Company()
            M_Comapny = New Model.M_Company()
            M_Comapny.Company_Logo = Convert.ToByte(browseCompanyLogo.Value)
            error_message = BL_Company.Company_Save(M_Comapny)
            If error_message > 0 Then
                MessageBox.Show("Complete Save")
            End If
        Catch ex As Exception
        End Try

 Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    End Sub

But It Shows Input Stream was not in a correct format . Why ? please !
Posted 28-Oct-12 18:02pm
Edited 31-Oct-12 20:07pm
heinhtataung at 1-Nov-12 1:59am
Nobody want to answer my quest?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You make sure your SqlDbType.Image or SqlDbType.Binary
cmd.Parameters.Add("@Company_Logo", SqlDbType.Image).Value = M_Model_DA.Company_Logo

If Image
Will it be need to convert byte
<pre lang="vb">Convert.ToByte(browseCompanyLogo.Value)</pre>

Hope be helpful,
heinhtataung at 1-Nov-12 4:30am
I change format toByte but still having error sis.. how can i do ? :(
Theingi Win at 1-Nov-12 4:59am
Is it IMAGE in the Store Procedure datatype? Pls let me know the error message.
heinhtataung at 1-Nov-12 6:06am
Yes sis, Now it is ok in saving at table. But... Now, i face with next problem.
How can i show that saved picture with pictureBox ?
heinhtataung at 1-Nov-12 6:07am
i used Store Procedure datatype.
Now , i finish saving image.
Now , the problem is how to retrieve to PictureBox ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

 M_Comapny.Company_Logo = IO.File.ReadAllBytes(browseCompanyLogo.Value.ToString())

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 263
1 stibee 249
2 Sergey Alexandrovich Kryukov 229
3 Suvendu Shekhar Giri 225
4 OriginalGriff 183
0 OriginalGriff 8,941
1 Sergey Alexandrovich Kryukov 8,493
2 Mika Wendelius 6,909
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 1 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100