Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
'In DA_Company'
VB
Function Company_Save(ByVal M_Model_DA As Model.M_Company) As String
       Try
           connection_enable()
           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'

VB
Function Company_Save(ByVal M_Company_BL As Model.M_Company) As String
      Try
          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'

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


'In Frm_Company'

VB
Private Sub Company_Save()
      Try
          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")
              Company_GridView_FillData()
          End If
      Catch ex As Exception
          MessageBox.Show(ex.Message.ToString())
      End Try


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

    End Sub





But It Shows Input Stream was not in a correct format . Why ? please !
Posted
Updated 31-Oct-12 20:07pm
v2
Comments
heinhtataung 1-Nov-12 1:59am    
Nobody want to answer my quest?

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
XML
<pre lang="vb">Convert.ToByte(browseCompanyLogo.Value)</pre>

in
VB
Frm_Company'




Hope be helpful,
Theingi.
 
Share this answer
 
Comments
heinhtataung 1-Nov-12 4:30am    
I change format toByte but still having error sis.. how can i do ? :(
Theingi Win 1-Nov-12 4:59am    
Is it IMAGE in the Store Procedure datatype? Pls let me know the error message.
heinhtataung 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 1-Nov-12 6:07am    
i used Store Procedure datatype.
Now , i finish saving image.
Now , the problem is how to retrieve to PictureBox ?
VB
M_Comapny.Company_Logo = IO.File.ReadAllBytes(browseCompanyLogo.Value.ToString())
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900