Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2004, 09:26 AM
Authorized User
 
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Varible

Does anyone know how to put information from a database (i.e. UserId) into a variable (i.e. VarUserID) and then add 1 to it. So now the new variable will be 2. Then insert the new variable value into the database.
My logic:
UserID=1
VarUserID = UserID
VarUserID = VarUserID + 1
UserID = VarUserID
Insert into database UserID

Thanks in Advance,
Mark

 
Old July 22nd, 2004, 10:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Will UserID be the Primary Key? And will the new value be a new row or are you updating the existing UserID?

 
Old July 22nd, 2004, 01:07 PM
Authorized User
 
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes UserID will be a Primary Key and YES this will be a new record in the table.

Mark

 
Old July 22nd, 2004, 01:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

  Public Function getMyID() As Integer
        Dim strConn As String = ConfigurationSettings.AppSettings("myDB")
        Dim objConn As New OleDbConnection(strConn)

        Dim strSQL As String = "SELECT the_id FROM the_database WHERE (email = '" & System.Web.HttpContext.Current.User.Identity.Name & "')"
        Dim objCommand As New OleDbCommand(strSQL, objConn)

        Dim sResult As Integer
        objConn.Open()
        sResult = CType(objCommand.ExecuteScalar(), Integer)
        objConn.Close()
        Return sResult
End Function

Now you can call another function or sub to increment getMyID() + 1 and send that value back to the database as a new row.

If you are using Access make sure Auto Increment isn't turned on.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Varible DB Name Mdingler SQL Server 2000 3 December 7th, 2006 10:21 PM
Using a varible to filter XML output animus XML 0 March 1st, 2006 02:49 PM
Passing a ASP varible to a javascript tdaustin Classic ASP Basics 1 May 17th, 2005 01:44 AM
Unique Control IDs inside a loop using a varible Joshua Sebastian Classic ASP Basics 2 February 3rd, 2005 10:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.