は私が写真を保存するには、Oracleを使用しています。あなたは、写真が格納されているフィールドと同じタイプのoutパラメータを持つ写真を取得する必要があります。私はそれがBLOBだと仮定します。写真をデータベースに保存する前に、それをバイト配列に変換する必要があります。これは問題ではないので、私は私のOracleデータベースから写真を取得するために使用するコードを投稿します.Sql Serverコードに変換するのは簡単なことです。
私はデータベースへの接続を開き、それを検索機能に渡します。 1行のデータ、写真、およびその他の識別情報を持つデータセットを返します。私はBLOBを変数に代入し、そこから必要なものを実行します。私がそれを行うのは、別のaspxページを呼び出して写真(imageURL)を取得するイメージコントロールに割り当てることです。それを取得するコードは、 "Image.aspx"と呼ばれ、写真を画像コントロールに返します。そのためのHTMLは、GetPhoto関数の下にあります。この方法で、私は写真をハードドライブのどこにでも保存してそれを検索する必要はありません。
Dim MyConnection As New OracleConnection
Dim MyDataSet As New DataSet
Dim MyPhoto() As Byte = {}
MyConnection = OpenConnection(Session("USERNAME"), Session("PASSWORD"))
MyDataSet = GetPhoto(MyConnection, pPhotoID)
myPhoto = MyDataSet.Tables("Data").Rows(0)("Photo")
Public Function GetPhoto(ByVal TheConnection As OracleConnection, ByVal pPhotoID As String) As DataSet
Dim myCommand As New OracleCommand
Dim DS As New DataSet
Try
With myCommand
.Connection = TheConnection
.CommandText = "Darlington.PlayerSignUps.GetPhoto"
.CommandType = CommandType.StoredProcedure
.Parameters.Clear()
.Parameters.Add(New OracleParameter("pPhotoID", OracleDbType.Varchar2, pPlayerID.Length)).Value = pPhotoID
.Parameters.Add(New OracleParameter("pDataOut", OracleDbType.RefCursor))
.Parameters(0).Direction = ParameterDirection.Input
.Parameters(1).Direction = ParameterDirection.Output
Dim DA As New OracleDataAdapter(myCommand)
DA.Fill(DS, "DATA")
GetPhoto = DS
End With
Catch exc As Exception
Throw New Exception("Error occured while retreiving photo from database, the error is: " & exc.Message)
End Try
myCommand = Nothing
End Function
<tr>
<td style="width: 372px; text-align: center">
<asp:Image ID="Image_Photo" runat="server" ImageUrl="Image.aspx" />
</td>
</tr>
[お問い合わせ]を読んで[ツアー]をご覧ください。また、あなたのタイトルは89,000のGoogleヒットと1,980件の投稿を返します。 – Plutonix