transact name habilitar for example enable ejemplos create activate sql-server-2008 asp-classic filestream

sql-server-2008 - name - habilitar filestream sql server 2017



¿Alguien ha usado ASP clásico con SQL Server 2008 y su nueva característica FileStream? (1)

Me estoy preparando para usar la capacidad FileStream de SQL Server 2008, pero no estoy seguro si Classic ASP puede leer y escribir desde SQL 2008 FileStream. Todavía tenemos una aplicación antigua que nos gustaría actualizar para admitir las cargas de archivos en la base de datos y nos gustaría considerar FileStream. Si es necesario, puedo construir un objeto COM a través de .NET para manejar esto, pero me gustaría saber si hay una mejor manera, ¡gracias!


Aquí hay un código de ejemplo. No lo probé, pero lo obtuve de http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_24772719.html :

Function Download_File(SQL_Txt As String, Conn As ADODB.Connection, FieldName As String, Fname As String, Optional FPath As String = "") As String Dim Z As Variant, I As Long, Fn As String, Max As Long, X As New ADODB.Recordset, Fx As New FileSystemObject Dim FieldType As ADODB.DataTypeEnum Const Delta = 32768 On Error GoTo Download_File_Err I = 1 Download_File = "" X.CursorLocation = adUseServer X.Open SQL_Txt, Conn, adOpenStatic, adLockReadOnly Max = X(FieldName).ActualSize FieldType = X(FieldName).Type If FieldType = adLongVarChar Then Z = X(FieldName).GetChunk(Delta) ''Legggi la porzione di file... Else ''FieldType =adLongVarBinary ->sicuramente! Z = BinaryToString(X(FieldName).GetChunk(Delta)) End If ''Apri-Crea il nuovo file e scrivi la prima porzione di file... Fx.OpenTextFile(Fn, ForWriting, True).Write Z While Len(Z) > 0 If FieldType = adLongVarChar Then Z = Nz(X(FieldName).GetChunk(Delta), "") Else Z = BinaryToString(X(FieldName).GetChunk(Delta)) End If ''Salva la porzione di file... Fx.OpenTextFile(Fn, ForAppending, False).Write Z I = I + 1 Wend X.Close Set Fx = Nothing Msg Download_File = Fn ''Segnala avvenuto scaricamento del file con nome e percorso... Exit Function Download_File_Err: MsgBox Err.Description Msg X.Close Set Fx = Nothing End Function Public Function Upload_File(SQL_Txt, Conn As ADODB.Connection, FieldName As String, Optional FPath_and_Name As String = "") As String Dim Z As String, L As Long, Fx As New FileSystemObject, X As New ADODB.Recordset Dim FieldType As ADODB.DataTypeEnum Const Delta = 16384 On Error GoTo Upload_File_err Upload_File = "" L = FileLen(FPath_and_Name) ''In questo caso si usa il cursore lato server... (Ma perchè il cursore lato client fallisce?) X.CursorLocation = adUseServer X.Open SQL_Txt, Conn, adOpenDynamic, adLockOptimistic FieldType = X(FieldName).Type If FieldType = adLongVarChar Then ''Leggi tutti i caratteri dal file... Z = Fx.OpenTextFile(FPath_and_Name, ForReading).Read(L) X.Update FieldName, Z Else Z = Fx.OpenTextFile(FPath_and_Name, ForReading).Read(L) X.Update FieldName, StringToBinary(Z) End If X.Close Msg Upload_File = FPath_and_Name Exit Function Upload_File_err: MsgBox Err.Description X.Close Msg End Function Function BinaryToString(ByteArray As Variant) As String ''--- Fast Converts the binary content to text ''Antonin Foller, http://www.motobit.com Dim X As New ADODB.Recordset, L As Long BinaryToString = "" If IsNull(ByteArray) Then Exit Function L = LenB(ByteArray) If L > 0 Then X.Fields.Append "mBinary", adLongVarChar, L X.Open X.AddNew ''In questo caso particolare AppendChunk converte l''array di byte ''in stringa! fantastico. X("mBinary").AppendChunk ByteArray X.Update BinaryToString = X("mBinary") End If X.Close End Function Function StringToBinary(S As String) As Variant ''Converts the string into a Binary array() ''Standard conversion... Dim I As Long, V As Variant StringToBinary = Null If S = "" Then Exit Function ReDim V(0 To Len(S) - 1) As Byte For I = 1 To Len(S) V(I - 1) = Asc(Mid(S, I, 1)) Next I StringToBinary = V End Function