Click here to Skip to main content
14,974,887 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends


datatype i am using image in db my requirement like this..not to store in folder

when i tried to insert image to database i am getting error like this

Conversion from type 'Byte()' to type 'Byte' is not valid

my code is

in bel

Dim _Image As Byte

VB
Public Property image()
        Get
            Image = _Image
        End Get
        Set(ByVal value)
            _Image = value
        End Set
    End Property



in present layer
in button click
VB
Dim len As Integer = ImgUpload.PostedFile.ContentLength
           Dim pic As Byte() = New Byte(len - 1) {}
           ImgUpload.PostedFile.InputStream.Read(pic, 0, len)
           objUserBAL.image = pic

           Dim objUserBLL As New bllCustomerInfo()
           OutPut = objUserBLL.InsertCustomerDetails(objUserBAL)





in DAL


Public Function InsertCustomerDetails(ByVal objUserDetails As balCustomerInfo) As String
Dim objUserDAL As New dalCustomerInfo()
Try
Return objUserDAL.InsertCustomerInformation(objUserDetails)

Catch ex As Exception
Throw ex
Finally
objUserDAL = Nothing
End Try

End Function


in BLL

Public Function InsertCustomerInformation(ByVal objBALUserDetails As balCustomerInfo) As String
Dim con As New SqlConnection(ConnectionString)
con.Open()
Dim cmd As New SqlCommand("spInsertCustomerInfo", con)
cmd.CommandType = CommandType.StoredProcedure
Try
'@customerId,@customerName,@totalLicReq,@validFrom,@validTo,@custComDet,@email,@cLogo,@lastUpdateon,@lastUpdateby
cmd.Parameters.AddWithValue("@customerName", objBALUserDetails.customerName)
cmd.Parameters.AddWithValue("@totalLicReq", objBALUserDetails.totalLicReq)
cmd.Parameters.AddWithValue("@validFrom", objBALUserDetails.validFrom)
cmd.Parameters.AddWithValue("@validTo", objBALUserDetails.validTo)
cmd.Parameters.AddWithValue("@custComDet", objBALUserDetails.customerCdet)
cmd.Parameters.AddWithValue("@email", objBALUserDetails.email)
cmd.Parameters.AddWithValue("@cLogo", objBALUserDetails.image)
cmd.Parameters.AddWithValue("@lastUpdateon", objBALUserDetails.lastUpdtedon)
cmd.Parameters.AddWithValue("@lastUpdateby", objBALUserDetails.lastUpdateBy)
cmd.Parameters.Add("@output", SqlDbType.VarChar, 100)
cmd.Parameters("@Err").Direction = ParameterDirection.Output
cmd.ExecuteNonQuery()
Dim strMessage As String = DirectCast(cmd.Parameters("@output").Value, String)
con.Close()
Return strMessage
Catch ex As Exception
Throw ex
Finally
cmd.Dispose()
con.Close()
con.Dispose()
End Try
End Function

can i help regarding this issue
Posted
Comments
[no name] 21-Jun-13 5:04am
   
Dim _Image As Byte()
Manohar_manu 21-Jun-13 5:15am
   
thank u its works

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