hey everyone i need help with navigating images in a database, i was able to insert image to a database. btw, i am using sql server 2005 and visual studio 2008. i only converted a sample code of visual c to .net and i was able to do so, but the problem is, i cant move through images...
here's my code for inserting an image into a database:
constr = "Data Source=CARLSATELITE\SQLEXPRESS;Initial Catalog=walalang;User ID=sa;Password=sa"
con = New SqlConnection(constr)
'Dim ra As Integer
'Dim fs As FileStream
'Dim rawdata As Byte()
OpenFileDialog1.ShowDialog()
fs = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
rawdata = New Byte(Convert.ToInt32(fs.Length)) {}
fs.Read(rawdata, 0, Convert.ToInt32(fs.Length))
Try
con.Open()
com = New SqlCommand("Insert into images (Image) values(@k)", con)
com.Parameters.AddWithValue("@k", rawdata)
ra = com.ExecuteNonQuery()
MsgBox("" & ra)
con.Close()
Catch ex As Exception
MsgBox(ex.ToString)
con.Close()
End Try
PictureBox1.Image = Image.FromStream(New MemoryStream(rawdata))
i also found a code for moving through records but i cant convert it to .net syntax because it is in c:
pictureBox1.Image = Image.FromStream(new MemoryStream((byte[])ds.Tables[0].Rows[i].ItemArray[0]));
i am having a problem particularly on byte[]..
please help me again guys..tnx in advance