Click here to Skip to main content
15,912,082 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: GSMComm Library Supported Modem. Pin
marvinit048829-Dec-10 2:57
marvinit048829-Dec-10 2:57 
QuestionExport to calendar Pin
m@dhu27-Jul-10 19:00
m@dhu27-Jul-10 19:00 
AnswerRe: Export to calendar Pin
Sandeep Mewara27-Jul-10 19:05
mveSandeep Mewara27-Jul-10 19:05 
GeneralRe: Export to calendar Pin
m@dhu27-Jul-10 19:14
m@dhu27-Jul-10 19:14 
GeneralRe: Export to calendar Pin
Sandeep Mewara27-Jul-10 19:21
mveSandeep Mewara27-Jul-10 19:21 
QuestionHandling digital camera images with System.Drawing Pin
NeverHeardOfMe27-Jul-10 11:33
NeverHeardOfMe27-Jul-10 11:33 
AnswerRe: Handling digital camera images with System.Drawing Pin
Luc Pattyn27-Jul-10 12:35
sitebuilderLuc Pattyn27-Jul-10 12:35 
GeneralRe: Handling digital camera images with System.Drawing Pin
NeverHeardOfMe27-Jul-10 14:21
NeverHeardOfMe27-Jul-10 14:21 
GeneralRe: Handling digital camera images with System.Drawing Pin
Luc Pattyn27-Jul-10 14:43
sitebuilderLuc Pattyn27-Jul-10 14:43 
GeneralRe: Handling digital camera images with System.Drawing [modified] Pin
NeverHeardOfMe27-Jul-10 21:57
NeverHeardOfMe27-Jul-10 21:57 
GeneralRe: Handling digital camera images with System.Drawing Pin
Luc Pattyn28-Jul-10 0:56
sitebuilderLuc Pattyn28-Jul-10 0:56 
GeneralRe: Handling digital camera images with System.Drawing Pin
NeverHeardOfMe28-Jul-10 1:13
NeverHeardOfMe28-Jul-10 1:13 
Questiondoubt in Classic ASP Pin
Xandip27-Jul-10 11:28
Xandip27-Jul-10 11:28 
AnswerRe: doubt in Classic ASP Pin
Ankur\m/27-Jul-10 18:38
professionalAnkur\m/27-Jul-10 18:38 
QuestionGenerate Sequential Number without database Pin
Maikeru200027-Jul-10 9:42
Maikeru200027-Jul-10 9:42 
AnswerRe: Generate Sequential Number without database Pin
Stoffy197227-Jul-10 9:50
Stoffy197227-Jul-10 9:50 
GeneralRe: Generate Sequential Number without database Pin
Yusuf27-Jul-10 10:07
Yusuf27-Jul-10 10:07 
GeneralRe: Generate Sequential Number without database Pin
Stoffy197227-Jul-10 10:21
Stoffy197227-Jul-10 10:21 
AnswerRe: Generate Sequential Number without database Pin
David Mujica27-Jul-10 9:57
David Mujica27-Jul-10 9:57 
AnswerRe: Generate Sequential Number without database Pin
Yusuf27-Jul-10 10:22
Yusuf27-Jul-10 10:22 
GeneralRe: Generate Sequential Number without database Pin
Maikeru20002-Aug-10 5:16
Maikeru20002-Aug-10 5:16 
AnswerRe: Generate Sequential Number without database Pin
T M Gray27-Jul-10 10:23
T M Gray27-Jul-10 10:23 
GeneralRe: Generate Sequential Number without database Pin
Maikeru200027-Jul-10 10:40
Maikeru200027-Jul-10 10:40 
GeneralRe: Generate Sequential Number without database Pin
T M Gray27-Jul-10 10:44
T M Gray27-Jul-10 10:44 
AnswerRe: Generate Sequential Number without database Pin
Adam R Harris28-Jul-10 8:52
Adam R Harris28-Jul-10 8:52 
Well if all you need is a simple way to do this you might try loading the last id from a flat text file or xml in Application_Start throw that into the application state and then in Application_End save it to the database. This way you dont have to worry about concurrency issues because the id is stored in memory and is only written back to the file when the application ends.

/* Global.asax */
void Application_Start(object sender, EventArgs e)
{
    int id;
    int.TryParse(System.IO.File.ReadAllText(Server.MapPath("~/nextid.txt")), out id);
    Application["ID"] = id;
}

void Application_End(object sender, EventArgs e)
{
    // Delete the old file
    System.IO.File.Delete(Server.MapPath("~/nextid.txt"));
    // Write out the new one
    System.IO.File.WriteAllLines(Server.MapPath("~/nextid.txt"), new string[] { Application["ID"].ToString() });
}

/* Some publicly accessible class */
public int GetNextID()
{
    // Increase the id
    Application["ID"] = Convert.ToInt32(Application["ID"]) + 1;
    return (int)Application["ID"];
}


Ofcourse you are going to want to add stuff like checking for the file before reading it and some error handling but im sure you get the point.
If at first you don't succeed ... post it on The Code Project and Pray.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.