Adding file information to SQL database on file upload

Hi there :)

I'm in the final stage of my asp.net project and one of the last things I need to do is add the following file information to my SQL server 2000 database when a file is uploaded:
First of all I have a resource table to which I need to add:
- filename
- file_path
- file_size
(the resource_id has a auto increment value)
so that should hopefully be straight forward when the file is uploaded. The next step is to reference the new resource_id in my module_resource table. My module resource table consists of:
- resource_id (foreign key)
- module_id (foreign key)
So, adding the module_id is easy enough as I can just get the value using Request.QueryString["module_id"]. The bit that I am unsure about is how to insert the new resource_id from the resource table into the module_resource table on file upload. How is this done? Using one table would solve the issue but I want one resource to be available to all modules - many to many relationship.
Any ideas?
Many thanks :)
0
Goatee
4/18/2004 7:41:13 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
868 Views

Similar Articles

[PageSpeed] 29
Get it on Google Play
Get it on Apple App Store

Since Resource_ID is an Identity column, you should be able to perform a SCOPE_IDENTITY() after the INSERT into the Resource table to pick up the value.

For example:

DECLARE @resourceID bigint
INSERT INTO
Resource
(
filename,
file_path,
file_size
)
VALUES
(
@filename,
@file_path,
@file_size
)
SELECT @resource_ID = SCOPE_IDENTITY()
INSERT INTO
Module_Resource
(
module_ID,
resource_ID
)
VALUES
(
@module_ID,
@resource_ID
)

Terri

Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
4/19/2004 2:33:14 PM
Reply:

Similar Artilces:

File Upload to server and save path to uploaded file into a sql database
   I am trying to upload a file to a server and save the path of the uploaded file to a sql 2005 server. I have some code below but im getting the error Object reference not set to an instance of an object. Any help would be greatful. By the way I got this code from these forums and just tweaked them for my website. 1 Dim Fileupload1 As FileUpload = CType(FindControl("FileUpload1"), FileUpload) 2 Dim filePath1 As Label = CType(FindControl("filePath1"), Label) 3 4 If Fileupload1.HasFile Then 5 Try 6 Fileupload1...

How to save Uploaded .pdf files to an sql database filed ? Please I Nedd Help It Very Urgent
I created insertdatafilelink.aspx to Insert an Uploaded .pdf files to a filed then when I run insertdatafilelink.aspx it inserts all data to all filed and Uploads the .pdf files to the folder Documents put it doesn't save the .pdf files to the fied file_link. This is the code I used Please I want to know where I made the mistake. 1-This Is the insertdatafilelink.vbPartial Class Insertdatatfilelink Inherits System.Web.UI.PageProtected Sub New_mail_system_ItemInserting(ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs) _ Handles New_mail_system.ItemInserting 'Refere...

Upload some files to a remote computer when some data is added to SQL database from an ASPX page
Hi all, I need to design a system that send off uploaded files (large) using WCF when the user upload a file to server from a ASPX page. I was thinking may be SQL has some kinds of event that I could use to trigger some other application and use that app to send the files to the remote computer using WCF ? is this possible at all ? or do you have any suggestions? ThanksSilverlight Rocks !...

"connections to SQL server files (*.mdf)" error message in Visual studio when adding a new SQL database
Hope you can help. Running Visual Studio 2005 and SQLServer2005.  I have created a new project and am attempting to add a new SQL database to it.  When I select the SQL database I get an "Connections to SQL server files (*.mdf) requires SQL Server Express to function properly" error message.  I also tried to add an existng database and it errors out as well "The file can not be opened as it is being used by another process.....".  However, I can create a new data source connection to existing SQL databases.  One caveat though.  I can ...

FTP Upload
Hi guys, I have a varchar(MAX) of xml data stored in the database (this is because the DOCTYPE DTD was causing problems when uploading to the database). What I want to do is retrieve this xml data from the database and upload it via FTP. The only tutorials I have seen are directly from a local file - is there anyway I can just stream it and then upload? Code would be very helpful if anyone has an example as I am completely stuck. Thanks, Mark mhbrown: is there anyway I can just stream it and then upload? Yes. If you have all you need to upload from a file stream you can s...

file uploader save file on server and in database and upload this file on client
hi,i have a file uploader control user can attach files (.rar, .zip, etc) and store file folder and path in database. and another user can click of attach link and can download that file. how can i do this please solve out this problem. you can find your problem solution in this link and you can store the file name in your database server.http://www.aspnettutorials.com/tutorials/network/net-fileupload-aspnet2-csharp.aspxPlease Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.comhttp://www.mitatdotnet.blogspot.com As always there are many ways and which ...

SQL Server Database File vs SQL Server Database -VWD Express
VWD Express 2008, SQL Server Express 2005. I have been using SQL Server Express with ASP and VB for some years - I just create a DB in Management Studio Express, have SQL Server set to 'SQL Server and Windows authentication', and use a connection string with 'sa' and a password (I never have managed to get it working with 'integrated security', but that is probably irrelevant to this post). So I have a list of DB's attached to SQL Server that I can see, attach, detach etc in MSE. I am getting started with .NET. Working through a VWD Express book tutori...

Upload file to SQL database
 Hi,I know that ASP.NET 2.0  has a FileUpload control. You specify the destination folder and the file gets uploaded there. That's cool. Now, let's say, I want the uploaded file to be streamed to the database.My question is : Can I stream file to the database without having a temporary folder on the server? If yes, wouldn't it produce a security risk? Thanks to everyone.  May be this link will help you.. http://www.kodyaz.com/articles/file-upload-and-save-to-sql-server.aspxMy Blog"Don't be afraid to be wrong; otherwise you'll never be right." ...

uploading files to sql database
Hi i want to create a page using c# in which i can upload files to an sql database, for instance a movie file, plus its actors, synopsis, running time e.t.c., Can someone tell me how i will be able to achieve this thank you. Hello Peter,Storing movie file in database is not a wise decision as size of movie file is huge so you will need a big db space which is expensive.However, if you still want to save then you have to convert the file into binary format and store in image data field.  Dim intImageSize As Int64 Dim strImageType As String Dim ImageStream As Stream...

Uploading Files to SQL database
I was following an example from the book "ASP.net unleashed" in Chapter 14, where it describes how to upload a file directly into the database. I got it to insert the file into my database as described, and with changes created a master and detail form to select the file and display it.. (which I assume had worked). Except, when attempting to access the file it gives two different errors. For a ppt file it gives: The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. An invalid ...

SQL Attached mdf database files VS database imported into or created in SQL Server 2005
 Hi all (newbie @ asp.net)(oldie @ ASP 3)What is the purpose of using an attached MDF database files in the App_Data folder on a web site as to importing it into the SQL server directly or creating it on the SQL server. Does a mdf database attached file purely use the SQL server as a connection interface.Is it something similiar to DSN(ODBC) Connections for ms access databases. AFAIK it is only for deployment conveniance, I have always imported the database directly into SQL Server and set up the connection string accordingly.Don't forget to click "Mark as Answer" on the...

Sql 2005 mdf files uprage to Sql 2008 mdf files ?
hiwhat is different between SQL 2008 Server and SQL 2005 Server ?SQL 2008 Server is more fast for searching ?i created my *.mdf at Sql 2005. does it work at SQL 2008 ? does it work same performance with *.mdf that created with SQL 2008 ? can i uprage my *.mdf for sql 2008 ? what should i do ? ThanksMark as me if my question or my answer can be helpful for you :) I posted this link before http://www.angryhacker.com/blog/archive/2008/06/20/10-reasons-why-sql-server-2008-is-going-to-rock.aspx You can upgrade your MDF to SQL Server 2008, but you would not be able to downgrade.Beware of bu...

Uploading files to server and adding new file to database
Hello guys, I need to enable client computers to be able to upload pictures to a folder on my server. After doing some search, I managed to get it working. Here's my code:   <script language="VB" runat="server">    Sub Upload(Source As Object, e As EventArgs)     If Not (myFile.PostedFile Is Nothing) Then      Dim intFileNameLength as Integer     Dim strFileNamePath as String     Dim strFileNameOnly as String      'Logic to find t...

how to clear SQL database LOG file in SQL express?
hwo to clear SQL database LOG file in SQL express? my SQL DB file size is 14MB, but the LOG FILE size is 50MB. i want to clear the log file, and also i would like to ask can i stop the LOG file function? BACKUP Log YourDBNAME With Truncate_Only USE YourDBNAME DBCC ShrinkFile (Logfilename,minsize)  ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips Some links to help you out Stop the transaction log of a SQL Server database from growing Shrink a log file, when it's full? DBCC SHRINKFILE (Transact-SQL)  ...

Web resources about - Adding file information to SQL database on file upload - asp.net.sql-datasource

Information - Wikipedia, the free encyclopedia
Information (shortened as info or info. ) is that which informs, i.e. an answer to a question, as well as that from which knowledge and data ...

InformationWeek – Latest Information Technology (IT) news & IT articles - Technology news - IT magazine ...
InformationWeek provides latest Information technology (IT) news online & articles and publishes latest tech news & IT magazine for Indian IT ...

Demand rises for drug information at dance music events
Demand is rising for support services at dance music events for help ranging from queries about illicit drugs to assistance through negative ...

Calvary Private Hospital failed to disclose cost information to patients: ACCC
Calvary Private Hospital failed to give patients sufficient information, leading some to experience &quot;bill shock&quot;.

2015 Fiesta Bowl: Preview, How To Watch, Ticket Information
Here’s everything you need to know about the New Year’s Day matchup between the Ohio State Buckeyes and the Notre Dame Fighting Irish.

Information Overload Causes Fatigue Among Smartphone Users
The Internet has connected humans to more information than ever. Between checking their phones dozens of times a day and constantly updating ...

Senate Intellicence Committee Chair Burr all but confirms that Cruz leaked classified information at ...
... that, among other things, updates the government’s program of collecting phone metadata. In doing so, Cruz probably leaked classified information. ...

Apple’s Maps app adds Los Angeles public transit information
Apple’s Maps application now supports public transit information for Los Angeles, California, forming a continuation of the service’s gradual ...

- Rosenblum will propose law on notifying people when their information has been hacked
SALEM — Oregon Attorney General Ellen Rosenblum told lawmakers on Wednesday the state’s privacy laws need to be updated to keep up with cyberthreats ...

Apple’s secrets: How Apple’s legal fight with Samsung revealed a gold mine of top-secret information
Following a contentious patent battle that raged on for nearly five years, Samsung last week finally agreed to pay Apple $548 million in damages ...

Resources last updated: 12/16/2015 5:13:34 PM