![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Saving files from SQL database to file server I have a SQL database table with files stored using the varbinary data type. I want to loop through this table and save all of the files to my file server. Connecting to the table and looping through it is no problem; I'm just looking for proper syntax for saving each file. I have the following fields (others also, but I figure these might be the important ones here): Contents - varbinary(max) MimeTypeDescription - nvarchar(255) Filename (This isn't a unique identifier in this case, so at best I can use it to find the original extension of the file.) UniqueName (which I'll have to use for the filename) Can anyone give me a code snippet that will get me started? Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Saving files from SQL database to file server bnick22 wrote: Quote: > I have a SQL database table with files stored using the varbinary > data type. I want to loop through this table and save all of the > files to my file server. Connecting to the table and looping through > it is no problem; I'm just looking for proper syntax for saving each > file. > > I have the following fields (others also, but I figure these might be > the important ones here): > > Contents - varbinary(max) > MimeTypeDescription - nvarchar(255) > Filename (This isn't a unique identifier in this case, so at best I > can use it to find the original extension of the file.) > UniqueName (which I'll have to use for the filename) > > Can anyone give me a code snippet that will get me started? > in an ASP file? -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Saving files from SQL database to file server VBScript file run from Windows. I have some experience with ASP.NET (VB), but the rest of the script is running in a simple .vbs file, and I'd like to simply append that. "Bob Barrows" wrote: Quote: > bnick22 wrote: Quote: > > I have a SQL database table with files stored using the varbinary > > data type. I want to loop through this table and save all of the > > files to my file server. Connecting to the table and looping through > > it is no problem; I'm just looking for proper syntax for saving each > > file. > > > > I have the following fields (others also, but I figure these might be > > the important ones here): > > > > Contents - varbinary(max) > > MimeTypeDescription - nvarchar(255) > > Filename (This isn't a unique identifier in this case, so at best I > > can use it to find the original extension of the file.) > > UniqueName (which I'll have to use for the filename) > > > > Can anyone give me a code snippet that will get me started? > > > in an ASP file? > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Saving files from SQL database to file server Well, the general idea is to use an ADO stream object to capture the binary output from the field and then use the SaveToFile method to save it to a file. I believe there may be an example in the ADO documentation which you can read here: http://msdn2.microsoft.com/en-us/library/ms675532.aspx More examples can be found via this google search: http://www.google.com/search?rlz=1C1...rom+SQL+Server bnick22 wrote: Quote: > VBScript file run from Windows. I have some experience with ASP.NET > (VB), but the rest of the script is running in a simple .vbs file, > and I'd like to simply append that. > > "Bob Barrows" wrote: > Quote: >> bnick22 wrote: Quote: >>> I have a SQL database table with files stored using the varbinary >>> data type. I want to loop through this table and save all of the >>> files to my file server. Connecting to the table and looping through >>> it is no problem; I'm just looking for proper syntax for saving each >>> file. >>> >>> I have the following fields (others also, but I figure these might >>> be >>> the important ones here): >>> >>> Contents - varbinary(max) >>> MimeTypeDescription - nvarchar(255) >>> Filename (This isn't a unique identifier in this case, so at best I >>> can use it to find the original extension of the file.) >>> UniqueName (which I'll have to use for the filename) >>> >>> Can anyone give me a code snippet that will get me started? >>> >> vbscript in an ASP file? >> >> -- >> Microsoft MVP - ASP/ASP.NET - 2004-2007 >> Please reply to the newsgroup. This email account is my spam trap so >> I don't check it very often. If you must reply off-line, then remove >> the "NO SPAM" Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Saving files from SQL database to file server Thanks very much for the help, Bob. You gave me enough information to find an answer. I adapted the code I found at http://www.tech-archive.net/Archive/.../msg00300.html. "Bob Barrows" wrote: Quote: > Well, the general idea is to use an ADO stream object to capture the binary > output from the field and then use the SaveToFile method to save it to a > file. I believe there may be an example in the ADO documentation which you > can read here: > http://msdn2.microsoft.com/en-us/library/ms675532.aspx > > More examples can be found via this google search: > http://www.google.com/search?rlz=1C1...rom+SQL+Server > > bnick22 wrote: Quote: > > VBScript file run from Windows. I have some experience with ASP.NET > > (VB), but the rest of the script is running in a simple .vbs file, > > and I'd like to simply append that. > > > > "Bob Barrows" wrote: > > Quote: > >> bnick22 wrote: > >>> I have a SQL database table with files stored using the varbinary > >>> data type. I want to loop through this table and save all of the > >>> files to my file server. Connecting to the table and looping through > >>> it is no problem; I'm just looking for proper syntax for saving each > >>> file. > >>> > >>> I have the following fields (others also, but I figure these might > >>> be > >>> the important ones here): > >>> > >>> Contents - varbinary(max) > >>> MimeTypeDescription - nvarchar(255) > >>> Filename (This isn't a unique identifier in this case, so at best I > >>> can use it to find the original extension of the file.) > >>> UniqueName (which I'll have to use for the filename) > >>> > >>> Can anyone give me a code snippet that will get me started? > >>> > >> In what context are you doing this? A vbs file on your desktop? Or > >> vbscript in an ASP file? > >> > >> -- > >> Microsoft MVP - ASP/ASP.NET - 2004-2007 > >> Please reply to the newsgroup. This email account is my spam trap so > >> I don't check it very often. If you must reply off-line, then remove > >> the "NO SPAM" > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Convert Database content into a file on the server | VB Script | |||
| Saving Data to a Disconnected (Temporarily Unreachable) Database | .NET General | |||
| Re: ASP.NET web server and sql database server on a old computer | .NET General | |||
| iis 5.1 can't connect to database server | .NET General | |||
| XP not saving File Properties Summary for jpeg files | Vista file management | |||