Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim data() As Byte
data = Request.BinaryRead(Request.TotalBytes)
Dim DateTaken As Date = ConvertDate(Request.QueryString("datetaken"))
Dim AssetNo As String = Request.QueryString("AssetNo")
Dim params(2) As SqlParameter
params(0) = New SqlParameter("DateTaken", DateTaken)
params(1) = New SqlParameter("AssetNo", AssetNo)
params(2) = New SqlParameter("Image", data)
InsertImage(params)
End Sub
Public Sub InsertImage(params() As SqlParameter)
Dim SQLString As String = "INSERT INTO Images (DateTaken, Image, AssetNo) VALUES (@DateTaken, @Image, @AssetNo)"
Dim myConnection As New SqlClient.SqlConnection(m_connString)
' Create a database command on the connection using query
Dim myCommand As New SqlClient.SqlCommand(SQLString, myConnection)
myCommand.Parameters.AddRange(params)
myConnection.Open()
myCommand.ExecuteScalar()
myConnection.Close()
myConnection.Dispose()
myCommand.Dispose()
End Sub
Public Function ConvertDate(AndroidDate As Long) As Date
Dim dt As New Date(1970, 1, 1)
dt = dt.AddMilliseconds(AndroidDate)
Return dt
End Function