Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a file to an Sql Server database using VBA

Status
Not open for further replies.

radubalmus

Programmer
Apr 26, 2007
49
EU
Hy
i need to attach a file(.xls) to a SQL Server database recordset using VBA.
do you have any ideeas, tips (an example would be great :))
Thanks

There are simple solutions for almost every problem! The hard part is to see them!!!!
 



Hi,

You cannot attach files to a dataase. A database consists of tables.

Do you want to...

1. Create a new table containing the data from one of the tables (sheets) in your workbook?

2. Append data from one of the tables (sheets) in your workbook to an existing table in the database.


Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Well it would have been great to attach the file to the database(something like you do in mails), because i have an .xls file with that is rather complicated it has 6 sheets, a lot of checkboxes, comboboxes...

What do you mean:
2. Append data from one of the tables (sheets) in your workbook to an existing table in the database

thanks


There are simple solutions for almost every problem! The hard part is to see them!!!!
 
To append data means to add additional records to it. I have an excel/vba app that that takes the excel data and appends new customerr records to my customer table, which is in a MS SQL Server 2000 database. The customer table has several hundred records in it.

As Skip said, you cannot add a file to a database. If you have an available field in your SQL table, you could put the file name and path of the file in that field as a reference with an update statement, but which record would this apply to?

What is the purpose of wanting to attach a file to a database? What business problem does this solve?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Someone told me he did it a few year ago, and he will look for the code to give it to me as example, he used an Ole Object type Field in Acces (like Image in Sql Server) but he didn't remember how..

it would be much easier for me to atach that file to a specific recordset(security reasons, i will query more easly).., and olso i really don't want to save the files in a folder on the server(storing the path in the database).

Also I just heard today about SQL Injection(didn't even cross my mind until now) and i am building most of my queryes dynamicly - any advice???

There are simple solutions for almost every problem! The hard part is to see them!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top