Solved

asp.net vb creating a unique id for insert form

Posted on 2010-11-16
3
505 Views
Last Modified: 2012-05-10
Hi,
We have a vb.net application within our office and we have recently been asked by a customer to facilitate the process of sending us data by providing an online portal whereby the information they send will be input directly in to our inhouse app (SQL server).

I have created an ASP.NET/VB application and created an input form. You dont need to log in or anything just navigate to the form, fill it in and then submit.
I have got the form working and once the required fields are completed you can click submit and my code uses an sql insert statement to input the data in to our sql server.

The problem is I also ask the user to upload several pictures. There are 4 tickboxes and when you tick each box there is an ajax file uploader.
The problem at the moment is all the images go in to a temporary folder and if more than one person is filling out the form at once that is a huge problem.

How can I assign a unique id to the page impression so I can in turn create a temp dir with the session id as its name - then once the insert statement has been made I can move the images to a new folder and delete the temporary one.
0
Comment
Question by:amgrobins
  • 2
3 Comments
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 500 total points
ID: 34146322
create an id field in your table
whenever you insert data use
select SCOPE_IDENTITY()
to get the last id inserted

http://msdn.microsoft.com/en-us/library/ms187342.aspx

then use this number to rename your temp files... or create a folder like this...

better you should use a stored procedure/function to insert the data

create procedure insData(... params here ...) as
begin
  insert into myData (...columns here...) values(...params here...);
  select SCOPE_IDENTITY()
end;

so, use this sp and get return value, create a temp folder, upload here, then use rename, move, delete...
0
 

Author Comment

by:amgrobins
ID: 34146526
the problem is I want to upload the files before the form is submitted (i.e before the sql insert).
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34147012
then use session id to create a temp folder
it is a unique id created by your web server
use this, create a temp folde rwith this name and upload here (each user will have different files in seperate folder)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question