.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Enter auto-incremented number to other tables in DB

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

Hi guys,

Im looking to take an auto-incremented Id#, CaseID, and insert that generated number into CaseID Columns in several other tables in that DataBase.  It was suggested to me to either use @@Identity, or SCOPE_IDENTITY(). I am not sure which one is most appropriate to my situation nor do I have the knowledge to make either of them work at the moment.  Was wonder what will be the best method to do this process.  I am using C# and asp.net 4.  Some code that i have so far:

DataSource on first page that will auto generate the id:

        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        InsertCommand="INSERT tblDemographics (Facility, Review, Quarter, PCN, Program, MR, DOB, Gender, SOC, Discharge, Reference, Diagnostic) 
                       VALUES (@Facility, @Review, @Quarter, @PCN, @Program, @MR, @DOB, @Gender, @SOC, @Discharge, @Reference, @Diagnostic)
                       SELECT @CaseID = SCOPE_IDENTITY()"
            <asp:Parameter Name="Facility" />
            <asp:Parameter Name="Review" />
            <asp:Parameter Name="Quarter"/>
            <asp:Parameter Name="PCN" />
            <asp:Parameter Name="Program" />

View Complete Post

More Related Resource Links

Auto number generation in windowsprint

Hi all, i want to know how generate auto number in windowsprint by using devexpress8.2 in vb.net  

SQL auto increment in two tables

Hi, i have a problem with auto increment. I generated auto ID with auto increment, but after this i need to insert new ID to other table. Is possible to generate same ID to both tables? Is possible to do it without select command?

How to find the Number of Tables Present in an XML File?

Dear All,Can any one let me know "How to find the number of Tables present in a XML Schema File"?Thanks and Regards,G.V.N.Sandeep

Auto-complete extender and default button of a panel - Enter key issues


Hi. I have a text box with an auto-complete extender attached to it. This is in a panel. Now, I have set the default button of the panel to the submit button of the panel.


      <text box/>




Now, I find that when the auto-complete options show up and I try to select an option using the enter key, the button is pressed (triggering a postback) due to it being the defaultbutton of the panel.

I want to be able to select an aut-complete option using the enter key and yet not post back. Therefore, the enter key (when the text box is in focus) should not trigger a postback. How can I achieve this?

Infopath 2007 Repeating Sharepoint List Sort Auto Number


Infopath 2007
Browser Enabled
Sharepoint List in a Repeating table

I have a view with a Sharepoint List showing in a repeating table. I have conditional formatting to hide items that should not show based on Line Total.

Line Total = 4

Approver    Min Amount        Max Amount  
Jim                      3                  9
Jack                    1                   7
Sally                   2                    5

Based on this, I need to sort the Approvers based on Max Amount and send an email to them in order of the sort.  Is this possible?


Deny Access to a number of tables.



I have set up a SQL Role and denied SELECT, INSERT, UPDATE, DELETE access to a number of tables.

I noticed that a user in this role can create a stored procedure containing a SELECT, INSERT, UPDATE or DELETE statement on the table that I have denied access to.

How could I stop the user in the role from being able to create/alter/execute stored procedure which use the tables than I have denied access to?

Also, the user in the role needs to be able to execute stored procedure on the tables which they are not denied access to.

Any help is appreciated.


How to add a auto genterated column in a sharepoint list of type number in SharePoint 2010


am try to generate a auto increment column for my SharePoint list of type number type?

=TEXT(1000+ID,0) , when i use this formula it works some time and some time it doesn`t increment?


do you know any out of box way to do this?

Thanks in Advance

Share Knowledge and Spread Love!

updating auto incremental sequence number in a column



can anybody tell me the quickest and perfect way to update the column with auto incremental sequence number without using cursor,while loop,temp table and using identity column, if possible in a single update statement.

I want output like







can this be possible in single update statement. Note that initially all the values in column col1 are either zero ar NULL



Sachin :)

Need an auto generating number for a document depending on a list column



I have an infopath form in my document library and I have list with columns Service ID and Service Name.

Base on the service id i need to generate another request id for the form starting from 0 for each service id as follows.

service 1---Id-1)Request form          

            ----Id-2)Request form  


service 2---Id-1)Request form

            ----Id-2)Request form  

Any little help would be much appreciated.



Auto generate a number in a text box in Infopath Form


Hello All,

I have a requirement of generating the auto number in one of the InfoPath form field(text box).I am designing this infopath form for Change Request in the organization.Can anyone help me  in doing it.

I appreciate your response.


Thank you,



SSIS : Pulling large number of tables from Source system



we are migrating a datawarehouse application from asp - sql 2000 to dotnet2.0 - sql 2005
currently we are in the process of coming up with an optimum solution for backend design using sql server 2005.
This application pulls data from 3 different source systems (oracle,sql server and mainframe db2).

we have 3 different staging databases corresponding to each of the source application database.
For eg : RetailGarments application is an oltp application with backend oracle database .
we have a staging SQL server database called Retailgarments_stg for our datawarehouse application.
similarly OnlineTravelBooking is an OLTP application with DB2 database .we have corresponding
OnlineTravelBooking_Staging database for staging this data.

Each of these source systems have more than 100 tables and we are currently pulling most of the
tables to our side from the source .

These staging data from different datasources are accumulated in to a cleansed Schema database
which is used for Reporting and other OLAP requirements.

Our question is related to data pull from the source system.
Current SQL Server database pulls these data from sorce system using Stored proc dynamic queries containing
link server openquery.

We would like to improve the performance as part of sql server 2000 to

How to Create Auto increment Request number for browser enable infopath form field Programmatically?

hi all,

i have created an infopath which have one request no. field and it will auto increment when click on add new item on sharepoint Document library

field contains (highest value of column request no. +1 )  when infopath will open in browser.

What i have done on this:i have create new data connection on sharepoint library and then pick document library then choose ID field and insert function in the field max(ID)+1.

help me



MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Temporary Tables - MS SQL Server

Usage of temporary tables in MS SQL Server is more developer friendly and they are widely used in development. Local temporary tables are visible only in current session while global temporary tables are visible across all sessions.

Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.

Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend