Function SaveImage _
(ByVal FileName As String) As Integer
Dim fi As New FileInfo(FileName)
Dim imgStream As Stream = _
fi.OpenRead
Dim imgData(imgStream.Length) As Byte
imgStream.Read(imgData, 0, fi.Length)
Dim cn As New SqlConnection _
(ConfigurationSettings.AppSettings("cn"))
Dim cmd As New SqlCommand("Images_ins", cn)
cmd.CommandType = CommandType.StoredProcedure
With cmd.Parameters
.Add("@FileName", VarChar, 100).Value = _
fi.Name
.Add("@FileType", VarChar, 10).Value = +
fi.Extension
.Add("@Image", Image).Value = imgData
.Add("@FileSize", Int, 4).Value = fi.Length
End With
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
cn.Dispose()
End Function