Solved

asp.net vb creating a unique id for insert form

Posted on 2010-11-16
3
504 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now