BLOB and SQLServer - Repost

This message is a repost. I am still looking for a solution and code examples would be FANTASTIC!! :slight_smile:

I have a new project that are rewrite of a currently existing application. The current application uses ASP w/SQLServer. The app is storing file attachements as BLOB’s. As part of the rewrite I need to move these attachments to a Notes database. Does anyone know of a way to do this. We currently have Notrix/Lyrix and it has been communicated to me that neither of these products perform the function I am describing. Any help/examples would be greatly appreciated.

Thanks in advance,

Steve

Subject: BLOB and SQLServer - Repost

How do you want them in Notes, as file attachments or custom field data or file resources or what?

Subject: RE: BLOB and SQLServer - Repost

I was thinking as file attachments in a rich text field, but am open to any ideas that gets the files from SQLServer to Notes documents.

Subject: BLOB and SQLServer - Repost

If you can get all the attachments to a folder, this will grab them one at a time and create a new notes document within the database that this code resides within:

Dim s As New Notessession

Dim db As Notesdatabase

Set db = s.Currentdatabase

Dim theFile As String

Dim pathName$

Dim fileName$

pathName$ = C:*.*"

fileName$ = Dir$(pathName$, 0)

’ Process all files in pathName$

Do While fileName$ <> “”

Messagebox fileName$

theFile = "C:" & fileName$

Set doc = New NotesDocument(db)

doc.Form = “Document” ’ ← change to correct form name

Set Body = New NotesRichTextItem(doc, “Body”) '<-- fieldname that holds attachment

Call Body.EmbedObject(EMBED_ATTACHMENT, “”, theFile)

Call doc.Save(True, False)

fileName$ = Dir$()

Loop

Subject: RE: BLOB and SQLServer - Repost

This is great. Thanks. Do you happen to have examples of how to generate the file from SQLServer (or any external db)? I am familiar with connecting to external db’s using lsxlc but an unclear on how to make the file.

Subject: RE: BLOB and SQLServer - Repost

Sorry, I’m not a bit familiar with SQLServer.I suggest to post again… optionally, you might seek a forum that specializes in SQLServer too.

:slight_smile:

Subject: RE: BLOB and SQLServer - Repost

If you already have the docs within the notes database, and there is a field which holds the name of the file you want to attach, this will grab that file and attach it and continue to the next doc, grab the file it needs and continue until done.

On Error Resume Next ’ just in case there is a fieldname problem… continue to next file

Dim s As New NotesSession

Dim db As NotesDatabase

Set db = s.currentdatabase

Dim viewdoc As NotesDocument

Dim view As NotesView

Set view = db.GetView( “(AllDocs)” ) 'create a view of the docs

'Iterate Through View

view.AutoUpdate = False

Set viewdoc = view.GetFirstDocument

Dim theFile As String

Dim pathName$

Dim fileName$

pathName$ = “c:*.*”

Dim rtitem As NotesRichTextItem

While Not ( viewdoc Is Nothing )

fileName$ = viewdoc.GetItemValue( “FileToAttach” )(0) ’ change this to field that holds fileattachment name

theFile = "C:" & fileName$

Set rtItem = viewdoc.GetFirstItem(“Body”) ’ change this to field that holds attachment

Call rtItem.EmbedObject(EMBED_ATTACHMENT, “”, theFile)

Call viewdoc.Save(True, False)

Set viewdoc = view.getnextdocument(viewdoc)

Wend

view.AutoUpdate = True