473,396 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Importing images to SQL Server 2005 Express Edition database

Hi,

Could someone give a pointer how to import couple of hundred images
into Sql Server 2005 Express Edition database?

Is there a tool for it? Can it be done with Sql Management Studio or
is it just a matter of writing own piece of software (a little helper
app) to do it?

-timonardo

Sep 5 '07 #1
1 3809
Could someone give a pointer how to import couple of hundred images
into Sql Server 2005 Express Edition database?

Is there a tool for it? Can it be done with Sql Management Studio or
is it just a matter of writing own piece of software (a little helper
app) to do it?
Below is a sample VBScript that will import all files in the specified
folder. This will work for SQL 2000 and SQL 2005. You can tweak this for
your needs. You can also use OPENROWSET in SQL 2005 (see Books Online), but
you'll need to provide your own method to provide the list of files to be
imported.

Const adOpenKeyset = 1
Const adLockOptimistic = 3
Const adTypeBinary = 1

Function Main()

Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Set fso = CreateObject("Scripting.FileSystemObject")
Set strm = CreateObject("ADODB.Stream")

'change connection string
ConnectionString = "Provider=SQLOLEDB" & _
";Data Source=MyServer" & _
";Initial Catalog=MyDatabase" & _
";Integrated Security=SSPI"

conn.Open ConnectionString
'change table and column names
rs.Open "SELECT File_Name, File_Contents FROM dbo.MyTable",
conn,
adOpenKeyset,
adLockOptimistic

'change folder name
Set folder = fso.GetFolder("C:\MyFiles")
Set fileList = folder.Files
For Each file In fileList
InsertFile(file.Name)
Next

conn.Close

Main = DTSTaskExecResult_Success

End Function

Sub InsertFile(FileName)

strm.Type = adTypeBinary
strm.Open
strm.LoadFromFile FileName
rs.AddNew
'change column names
rs.Fields("File_name") = FileName
rs.Fields("File_Contents") = strm.Read
rs.Update
strm.Close

End Sub

--
Hope this helps.

Dan Guzman
SQL Server MVP

"pompair" <ti*******@gmail.comwrote in message
news:11*********************@19g2000hsx.googlegrou ps.com...
Hi,

Could someone give a pointer how to import couple of hundred images
into Sql Server 2005 Express Edition database?

Is there a tool for it? Can it be done with Sql Management Studio or
is it just a matter of writing own piece of software (a little helper
app) to do it?

-timonardo
Sep 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
2
by: farseer | last post by:
Hi, I have SQL Server 2005 installed on my dev system. I am working on an app that i would like to distribute SQL Server with. SQL Server EXpress edition seem to be ideal for this. My questions...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
2
by: kress1963nov22 | last post by:
I recently purchased a good MS book ("Build a Web Site Now") by Jim Buyens. It has the Express Edition of MS-Visual Web Developer 2005 on CD and also MS SQL Server 2005 Express Edition on the CD. A...
4
by: Goofy | last post by:
The add database ( MDF ) in Visual Studio 2005 seems to be in SQL Server 2005 format as far as I can tell. Does anyone know how I can import tables ( without having to start writing queries ) from...
5
by: Glen Buell | last post by:
Hi all, I have a major problem with my ASP.NET website and it's SQL Server 2005 Express database, and I'm wondering if anyone could help me out with it. This site is on a webhost...
3
by: Steve | last post by:
Hi All I downloaded Sql server 2005 express SP2 and attempted to modify the Bootstrapper package files as I did with SP1 When i try to install SQL server as part of my VS 2005 deployment app I...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
10
by: Scott M. | last post by:
I've seen many posts and ready articles discussing how changing the membership & roles "provider" in VS .NET is easy, but have yet to see instructions on how to do it. If I already have SQL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.