Passing Var's to Procedure


G

Guest

I am using VB.net, ADO.net and trying to insert images to a SQL table, the
procedure below it works but how and what I need to change such that I can
pass (i.e.) catergories, picture, categoryName as variables? thanks for any
help




Private Sub File2SqlBlob(ByVal SourceFilePath As String)
Dim cn As New SqlConnection("server=localhost;integrated
security=yes;database=NorthWind")
Dim cmd As New SqlCommand("UPDATE Categories SET [email protected]
WHERE CategoryName='Test'", cn)
Dim fs As New System.IO.FileStream(SourceFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fs.Length() - 1) As Byte
fs.Read(b, 0, b.Length)
fs.Close()
Dim P As New SqlParameter("@Picture", SqlDbType.Image, b.Length,
ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b)
cmd.Parameters.Add(P)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top