-1

Webサーバーのディスクに画像があり、画像を取得してMSSQL(2005)データベース(画像データ型列)に保存するスクリプトをクラシックasp(vbscript)で記述したいと思います。SQLデータベースは別のサーバー上にあります

どんな助けでもいただければ幸いです。

ありがとう、

4

2 に答える 2

0

MSSQLイメージのデータ型は「byte[]」配列です

byte[] buffer = File.ReadAllBytes("Path to file");

このバッファを使用して、MSSQLテーブルの画像列に挿入します

これで、MSSQLコマンドは次のようになります

SqlCommand cmd = new SqlCommand("INSERT INTO <your_table_name> (ImageColumn) values (@parameter)");
cmd.Parameters.AdWithValues("@parameter",buffer);
于 2013-03-04T17:39:46.980 に答える
0

お手伝いありがとう。従来のASPでこれを行う方法を理解したと思います

strFilePath = Server.MapPath("your file")

Set oConn = Server.CreateObject("ADODB.Connection")
With oConn 
.connectiontimeout = 0
.commandtimeout = 0
.connectionstring = <your connection string>
.cursorlocation = 3 'adUseClient
.open
End With

Set oStream = Server.CreateObject("ADODB.Stream")
oStream.Type = 1 'AdBinary
oStream.Open
oStream.LoadFromFile strFilePath
xBin = oStream.Read

Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
strSql = "INSERT INTO dbo.YourTable (strImage) VALUES(?);"
oCmd.CommandText = strSql
oCmd.Parameters.Item(0) = xBin
Set oRs = oCmd.Execute
Set oRs = Nothing
Set oStream = Nothing
Set oConn = Nothing
于 2013-03-05T19:14:43.343 に答える