Solved

asp.net vb creating a unique id for insert form

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

23 Experts available now in Live!

Get 1:1 Help Now