1

私はこれにかなり慣れていないことから始めましょう。数日間答えを見つけようとしていることが明らかな場合は申し訳ありません!

データベースのvarbinaryにバイト[]を挿入しようとしていますが、レンガの壁にぶつかっているので、誰かが助けてくれることを願っています. これまでのところ、私は持っています:

Dim biData, matchId
Dim sConnString, connection, recordset, sql, count

biData = Request.BinaryRead(Request.TotalBytes)
matchId = Request.ServerVariables("QUERY_STRING")

sql = "SELECT * FROM MatchData WHERE matchId= '" & matchId & "'"

'define the connection string, specify database
'driver and the location of database
sConnString="Driver={SQL Server};<CONNECTIONSTRING>"

Set connection = Server.CreateObject("ADODB.Connection")
Set recordset = Server.CreateObject("ADODB.Recordset") 

'Open the connection to the database
connection.Open(sConnString)

'Open the recordset object executing the SQL 
recordset.Open sql, connection,3,3

count=recordset.recordcount

If count > 0 Then
    response.Write("Found  ")
    recordset.Update "MatchId", matchId

    'MY PROBLEM IS HERE
    'recordset.Update "MatchData", biData
    'recordset.Fields("MatchData").AppendChunk biData
Else
    response.Write("Not Found  ")
    recordset.AddNew "MatchId", matchId

    'MY PROBLEM IS ALSO HERE
    'recordset.Update "MatchData", biData       
    'recordset.Fields("MatchData").AppendChunk(biData)
End If

recordset.Close
Set recordset=Nothing

'Done. Close the connection object
connection.Close
Set connection = Nothing

biData を返すだけで、アップロードした正確な byte[] が表示されるので、そこにあると思います。つまり、response.BinaryWrite biData

ご回答ありがとうございます。

4

1 に答える 1

0

バイナリ (チャンク) をループに追加する必要があります。

このページを確認してください: http://msdn.microsoft.com/en-us/library/windows/desktop/ms678200(v=vs.85).aspx

特に、それを行う方法に関するコードのこの部分:

Cnxn.Execute "INSERT publishers(pub_id, pub_name) VALUES('" & _
               strPubID & "','Your Test Publisher')"

' Add a new record, copying the logo in chunks
rstPubInfo.AddNew
rstPubInfo!pub_id = strPubID
rstPubInfo!pr_info = strPRInfo

lngOffset = 0 ' Reset offset
Do While lngOffset < lngLogoSize
    varChunk = LeftB(RightB(varLogo, lngLogoSize - lngOffset), _
        conChunkSize)
    rstPubInfo!logo.AppendChunk varChunk
    lngOffset = lngOffset + conChunkSize
Loop
rstPubInfo.Update
于 2013-02-04T04:12:15.590 に答える