2010-01-11 1 views

답변

1

File.ReadAllBytes을 호출하여 파일을 바이트 배열로 읽을 수 있습니다.

그런 다음 SqlParameter을 사용하여 바이트 배열을 SQL Server에 넣을 수 있습니다. 예를 들어

:

Using command As New SqlCommand("INSERT INTO sometable VALUES(@image)", connection) 
    command.Parameters.AddWithValue("image", File.ReadAllBytes(path)) 
    command.ExecuteNonQuery() 
End Using 
+0

감사 sLaks. 하나의 질문. 이미지가 내 C 드라이브에 있지 않습니다. 서버의 위치에 있습니다. 어떻게 읽을 수 있습니까? My.Computer.FileSystem.ReadAllBytes _ ("C :/Documents and Settings/selfportrait.jpg") 이것은 파일의 위치 Server.MapPath ("images \ Signatures \") & Session ("NetworkID"). ToString() & ".jpeg") – acadia

+0

로컬 디스크에있는 한 계속 읽을 수 있습니다. 사용자가 업로드했다면,'File.load '컨트롤의'Request.Files [0] .InputStream' 또는'FileBytes' 속성을 읽어 바이트 배열을 얻을 수도 있습니다. – SLaks

관련 문제