.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

How to Capture @@identity???

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
Hi,As I read, @@Identity returns the last Identity value. In my Page, what I would like to happen is for the client to enter data on Page1 - where I would like to capture the ID that has been added in Page1 for Page 2 to update the status.in my Page1 code: con1 = New SqlConnection(ConnectionString) strInsert = "INSERT INTO Media (Title,AssetCode,DateAdded,Status)" & _ " values (@Title,@Assetcode,@Date,@Status)" newID.CommandText = "SELECT @@Indentity from Media" newID.Connection = con1 cmdInsert = New SqlCommand(strInsert, con1) cmdInsert.Parameters.AddWithValue("@Title", s) cmdInsert.Parameters.AddWithValue("@Assetcode", s1) cmdInsert.Parameters.AddWithValue("@Date", Now) cmdInsert.Parameters.AddWithValue("@Status", "Editing") con1.Open() cmdInsert.ExecuteNonQuery() 'This is my current pain here... Session("refID") = newid.executescalar().tostring() con1.close() Response.Redirect("Page2.aspx") 'where the supposedly newid is carried so I can update the values in the table Regards,

View Complete Post

More Related Resource Links

Pass ASP.NET membership identity object across domain?


I am trying to figure a way to SSO with ASP.NET membership and role model.

I can implement custom membership provider which consume web services hosting on a server.

With encryption of data. No problem.

But my question is, If I sign on a website with my provider, got my identity object on that application,

could I pass it to another website on another domain which use the same provider and by doing so, do not need to login again?

If this is possible, I am going to implement this solution. Please tell me what's your take on this.

Federated Identity: Passive Authentication for ASP.NET with WIF


The goal of federated security is to provide a mechanism for establishing trust relationships between domains. Platform tools like Windows Identity Foundation (WIF) make it much easier to support this type of identity federation. We show you how.

Michele Leroux Bustamante

MSDN Magazine August 2010

AD FS 2.0 in Identity Solutions: Using Active Directory Federation Services 2.0 in Identity Solution


This article explains how you can use Active Directory Federation Services (AD FS) 2.0 to claims-enable Windows Communication Foundation (WCF) services and browser-based applications. The focus is on the token issuance functionality in AD FS 2.0. You'll find out how to use AD FS 2.0 as an identity provider; set up an AD FS 2.0 security token service (STS) to interact with WCF; federate AD FS 2.0 with your custom STS or another AD FS 2.0; enable Web single sign-on and federation with WS-Federation and SAML 2.0 protocols; and externalize authentication logic through Visual Studio. You'll come away appreciating how AD FS 2.0 and Windows Identity Foundation make programming identity solutions in Windows less of a chore.

Zulfiqar Ahmed

MSDN Magazine November 2009

Form Filler: Build Workflows to Capture Data and Create Documents


Learn how to create a workflow that uses InfoPath forms and other office documents for passing data to targeted activities and for use in Office documents.

Rick Spiewak

MSDN Magazine June 2008

Security Briefs: Exploring Claims-Based Identity


Keith Brown introduces you to the new identity model in the Microsoft .NET Framework 3.0.

Keith Brown

MSDN Magazine September 2007

Identity: Secure Your ASP.NET Apps And WCF Services With Windows CardSpace


Windows CardSpace replaces traditional authentication with a more consistent and streamlined login process and improves trust between end-users, applications and services. Michèle Leroux Bustamante explains.

Michele Leroux Bustamante

MSDN Magazine April 2007

Capture event from HierarchicalDataSource


I have a custom hierarchical data source based on the msdn example (http://msdn.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx).  An event can be raised in the DataSourceView.  If that occurs, I want to display a message on the web page.

The example is that I have a page with a TreeView control which uses a custom hierarchical datasource.  If the user selects a node that they are not allowed to select, the underlying datasource will throw and error.

I want to capture this and add a message to the page.  The Page_Error event is raised, but there are no eventargs.

Anybody know how to capture such an event? 

An alternative approach, although not quite specific enough, is to set a flag during the datasource load event (indicating the datasource is loading) and test for this flag in the Page_Error routine.

How to capture ReportViewer Mouse Events


I have a ReportViewer which I'm pulling into a C# WPF project, and would like to be able to capture the row a user clicks on in the reportViewer, but have had no success tapping into the mouse event handlers.   Does anyone know how to accomplish this?  

This MSDN link seems to imply that ReportViewer(winforms) supports mouse click events such as Click, DoubleClick..etc.  http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer_events.aspx, but I've not had any luck.

If mouse events are not currently supported, does anyone know when they will be, and whether properties such as SelectedItem or SelectedIndex would also be exposed?

Thanks for the help.

Issue with Web capture webpart configuration


I have a requirement to display a specific are of page.
I think we can do it by using web capture webpart. when i try to modify the properties of webcapture webpart it prompts an message"Cannot create or modify Web Capture. Make sure that your browser supports ActiveX controls , that you have enabled them, and that you have installed the Web Capture ActiveX control".
I have installed "owc11" coponent but of no use. i am using IE 7...

can anyone please suggest how to solve this issue?


Capture Url and do redirect



I am writing a http module, Want to find out how can i capture a URL and the do a redirect in case of certin conditions met?

Aajaxtoolkit control +

dear all,   i have propblem, when i put  <identity impersonate="true" userName="domain\username" password="password" />   i have the following erro: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.   but if i remove this tag : <identity impersonate="true" userName="domain\username" password="password" /> this site work normally. and i need to put this tag in web.config.

Windows Identity Foundation Security Token Service can't stay logged in

I'm using the Windows Identity Foundation **(WIF)** Security Token Service **(STS)** to handle authentication for my application which is working all well and good. However I can't seem to get any long running login with the STS. From my understanding I shouldn't care about the client tokens at the application level since they can expire all they want to and it should redirect me to the STS and as long as they're still logged in on the STS it should refresh their application token. Yet it doesn't seem to want to keep them signed in. Here's what occurs in my login.aspx on the STS var cookie = FormsAuthentication.GetAuthCookie(userName, persistTicket); if (persistTicket) cookie.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); var returnUrl = Request.QueryString["ReturnUrl"]; Response.Redirect(returnUrl ?? "default.aspx"); Which was taken almost directly from existing application using normal Forms Auth. From my web.config <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="2880" name=".STS" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /> </auth

What pattern do I use to capture an entire C# method definition with all modifiers, method name and

Hello all,Given a C# method named MyMethod, what pattern do I use to capture the entire definition, including modifiers, method name and opening and closing braces, irrespective of bracket styles, given that the method will probably contain 1-n other pairs of braces, embedded or not, etc? In this case, I don't care about the actual method definition, I just need to capture it all in one chunk.    a. public int MyMethod(int parm){            if (...) {            }       }    b. public int MyMethod(int parm)       {            if (...) {            }       }Thanks in advance for any ideas and/or suggestions!

SQL DIAGOSITC MANAGER tools capture "SELECT *" statement while ALTER / ADD CHECK CONSTRAINT is execu

Hello  ,   I exectuted the code(alter/add with check)  below in SSMS . My_table has 200 millions records . While running the alter/add with check query  the server crashed and the “SQL DIAGOSITC MANAGER” which run on the top of sql serever alert the DBA that select * from my_table was obtained from the last command issued by the user using a DBCC command.      Where does the select * from my_table comes from ? I didn’t excuted select * from my_table at all .   After the sql serever re started I was able to run the command below with out any problem. I checked the SQL PROFILER for the trace there is no “select * from my_table” .   So again where this select * from my_table comes from ?   Here is my initial query ----------------------------------------------------------------- ALTER TABLE [Dbo].my_table WITH CHECK ADD  CONSTRAINT [FK_key1] FOREIGN KEY([Key1]) REFERENCES [Dbo].[Dim_table1] ([Key1]) GO   ALTER TABLE [Dbo].my_table CHECK CONSTRAINT [FK_key1] GO   ALTER TABLE [Dbo].my_table WITH CHECK ADD  CONSTRAINT [FK_key2] FOREIGN KEY([key2]) REFERENCES [Dbo].[Dim_table2] ([key2]) GO   ALTER TABLE [Dbo].my_table CHECK CONSTRAINT [FK_key2] GO   ALTER TABLE [Dbo].my_table WITH CHECK ADD  CONSTRAINT [FK_key3] FOREIGN KEY([d], [c], [r], [g]) REFERENCES [Dbo].my

Replication and auto Identity Increment

We want to have two SQL server working on the same data at the same time (SQL Server 2008). I've been told that the auto ID's will stop working (the identity option). I'm not sure how true this is or what is the best replication to use for this.   Thanks

Fetch Identity column just after inserting a row in table

Hi, Please help me with this question. I have a table and I insert a row into it. How can i select the latest inserted row? Can the 'inserted table' keyword be used outside trigger? ( I mean can we use it in above scenario?? If yes how)   Thanks in advance Tiya

Yet another WPF Screen Capture (with Rectangle) App

  The Plan:         I had plan on adapting the following, which is an old Microsoft sample implementing of a rubberband rectangle for my app               http://support.microsoft.com/kb/314945         To simulate a selectable area to capture i would display a wpf window over the entire desktop and make it transparent. Then i would use the window as the surface on which to do the mouse area selection and draw the rubberband rectangle on the mouse move.  I would then pass the point coordinates of the rectangle to this bit of code to do the actual capture. public static BitmapSource Copy(int left, int top, int right, int bottom) { using (var screenBmp = new Bitmap(right - left, bottom - top, PixelFormat.Format32bppArgb)) { using (var bmpGraphics = Graphics.FromImage(screenBmp)) { bmpGraphics.CopyFromScreen(left, top, right, bottom, screenBmp.Size); return Imaging.CreateBitmapSourceFromHBitmap( screenBmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } } } The Malady:         When i make the wpf window transparent i completely loose it as a surfa
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