mattster6060
New member
- Joined
- Dec 15, 2011
- Messages
- 2
- Programming Experience
- 3-5
Afternoon,
I have an issue with the below vb.net code, its fails at the highlighted step below with 'Out Of Memory', can anybody shed any light as to why this is happening?
Cheers,
Mattster
I have an issue with the below vb.net code, its fails at the highlighted step below with 'Out Of Memory', can anybody shed any light as to why this is happening?
VB.NET:
Try
Dim da As SqlDataAdapter = New SqlDataAdapter()
Dim cmd As SqlCommand
Dim conn As New SqlConnection()
conn.ConnectionString = "Data Source=******;Initial Catalog=****;User Id=****;Password=*****;"
' Create the SelectCommand.
cmd = New SqlCommand("SELECT Employee.photo FROM Employee INNER JOIN Users ON Employee.Rn_Employee_User_Id = Users.Users_Id WHERE (Users.Login_Name = @User)", conn)
cmd.Parameters.Add("@User", SqlDbType.NVarChar, 15)
cmd.Parameters("@User").Value = user
da.SelectCommand = cmd
conn.Open()
Dim barrImg As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
Dim strfn As String = Convert.ToString(DateTime.Now.ToFileTime())
Dim fs As New IO.FileStream(strfn, IO.FileMode.CreateNew, IO.FileAccess.Write)
fs.Write(barrImg, 0, barrImg.Length)
fs.Flush()
fs.Close()
[COLOR=#ff0000][B]Picturebox1.Image = Image.FromFile(strfn, False)
[/B][/COLOR] Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Cheers,
Mattster