Ok I think I am close but am doing something wrong... Basically I have a directory of images that I am trying to import into a SQL table via Stored Proc... Getting the error:
No mapping exists from object type System.IO.FileStream to a known managed provider native type.
vb Code:
Dim stFileDir As String = "U:\styleimages" Dim cmd As New SqlCommand conn.Open() With cmd .Connection = conn .CommandType = CommandType.StoredProcedure .CommandText = "InsertStyleImage" For Each FileName As String In Directory.GetFiles(stFileDir) Dim MyFileInfo As New FileInfo(FileName) .Parameters.Clear() .Parameters.AddWithValue("@ImageName", MyFileInfo.Name) .Parameters.AddWithValue("@ImageData", MyFileInfo.OpenRead) .Parameters.AddWithValue("@ImageSize", MyFileInfo.Length) .Parameters.AddWithValue("@ImageType", MyFileInfo.GetType) .Parameters.AddWithValue("@StyleNo", " ") .ExecuteNonQuery() Next MsgBox("Done!") End With conn.Close() End Sub
I am guessing it is in MyFileInfo.OpenRead but not sure what I should use.




Reply With Quote