Exit Sub
End Select
ImgPhoto.ImageUrl = fpPhoto.PostedFile.FileName
'Connect to the database and insert a new record into Products
Dim imageBytes(fpPhoto.PostedFile.InputStream.Length) As Byte
fpPhoto.PostedFile.InputStream.Read(imageBytes, 0,
imageBytes.Length)
Photo = imageBytes
' Session("Photo") = Photo
Catch ex As Exception
Throw ex
End Try
End Sub
------------------------------
update called by following
---------------------------------
Photo = CType(Session("Photo"), Byte())
UpdatePH_ID(Session("PH_ID_NO"), Session("DistID"), Photo)
--------------------------------------------------------------
CLASS FILE
------------------------
-----------------------
member Variable
-----------------
Private mPhoto As Byte() = Nothing
---------------
Property
---------------------
Public Property Photo() As Byte()
Get
Return mPhoto
End Get
Set(ByVal Value() As Byte)
mPhoto = Value
End Set
End Property
--------------
function
---------------
Public Sub UpdatePH_ID(ByVal id As Integer, ByVal id1 As Integer, ByVal p As
Byte())
'Make the object of the class that is supporting this Web Service
'Make the dataset that is to be used thoughout here
Dim objParameter As New cParameter(ds)
'Make the objParameter ready for insert
getCollection(objParameter, 2, id, id1, p, False)
'Make the dataset ready by filling it
If objservices.UpdateSJEDPH_ID1PhotoData(ds) = 1 Then
MsgBox("Photo for the current document is updated!")
End If
End Sub
Private Sub getCollection(ByRef objParameter As cParameter, ByVal index
As Int16, ByVal id As Integer, ByVal id1 As Integer, ByVal p As Byte(),
Optional ByVal common As Boolean = False)
If IsNothing(objParameter) Then
objParameter = New cParameter(ds)
End If
'objParameter.CreateParameter(dsEntry, "UserID",
My.Application.UserInfo.UserID.ToString)
'objParameter.CreateParameter(dsEntry, "OfficeID",
My.Application.UserInfo.OfficeID.ToString)
'objParameter.CreateParameter(dsEntry, "RoleID",
My.Application.UserInfo.RoleID.ToString)
Dim param As SqlParameter() = New SqlParameter(2) {}
param(0) = New SqlClient.SqlParameter("@PH_ID_NO1", ID)
param(1) = New SqlClient.SqlParameter("@dist_cd", id1)
param(2) = New SqlClient.SqlParameter("@Photo", p)
Dim drEntryPage As DataRow
ds.Tables("Parameter").Columns.Add("Photo", GetType(Byte()))
ds.Tables("Parameter").Columns.Add("Thumb", GetType(Byte()))
drEntryPage = ds.Tables("Parameter").NewRow()
SetValue(drEntryPage)
ds.Tables("Parameter").Rows.Add(drEntryPage)
End Sub
Private Sub SetValue(ByRef drEntryPage As DataRow)
Try
With drEntryPage
'.Item("SrNo") = DBNull.Value
'.Item("DocumentID") = DBNull.Value
'.Item("DocumentRefID") = DBNull.Value
'.Item("PhotoThumbID") = strPK
.Item("PName") = "Photo"
.Item("PValue") = Photo
.Item("PType") = enmParameterType.Input
.Item("DBType") = SqlDbType.Image
.Item("Photo") = Photo
'.Item("UserID") = My.Application.UserInfo.UserID
'.Item("OfficeID") = My.Application.UserInfo.OfficeID
'.Item("RoleID") = My.Application.UserInfo.RoleID
End With
Catch ex As Exception
Throw ex
End Try
End Sub
----------------------
web services
-----------------------
<WebMethod()> _
Public Function UpdateSJEDPH_ID1PhotoData(ByRef ds As DataSet) As
Integer
Dim param As SqlParameter() = Nothing
Dim id As Integer
Dim i As Integer
param = New SqlParameter(ds.Tables(0).Rows.Count - 1) {}
For i = 0 To ds.Tables("Parameter").Rows.Count - 1
If Not IsDBNull(ds.Tables(0).Rows(i).Item(1)) AndAlso
ds.Tables(0).Rows(i).Item("DBType").ToString = "Image" Then
param(i) = New
SqlParameter(ds.Tables(0).Rows(i).Item(0).ToString,
ds.Tables(0).Rows(i).Item("Photo"))
Else
param(i) = New
SqlParameter(ds.Tables(0).Rows(i).Item(0).ToString,
ds.Tables(0).Rows(i).Item(1))
End If
Next i
id = SqlHelper.ExecuteScalar(getConnectionString(),
CommandType.StoredProcedure, "UpdateSJEDPH_ID1PhotoData", param)
Return id
End Function