Getting Identity Of The Saved Record?
May 12, 2010[code]....
i am using linq how would i going to get the identity in the code above.
[code]....
i am using linq how would i going to get the identity in the code above.
I am developing a asp.net application and i am using SQL Server 2008. I took a IDENTITY column as Record_ID for detail table where i will have trillions of records per year. So just want to ask whats the largest number record id (identity) column can hold and in ASP.NET which data type i should use to handle record id as i am using this id as a reference to update the table data. I don't want to end up being trapped some day.
View 1 RepliesI need to save some data and return the ID that is created in the SQL 2005 database. I need the ID to pass to another object before saving that so I can associate them correctly.
What is the best way to accomplish this with Ext? Is there anything built into the Framework that makes this simple?
function AddPromotionType() {
var currentDate = new Date();
var newTypeJsonObject = {
promotionTypeId: '0',
promotionType: Ext.getCmp('txtPromoType').getValue(),
updatedBy: userid,
[Code]....
I would like to show a modal ui-dialog when a record is successfully saved to the database.
View 8 Repliesi have maked a form which is saving used detail . how we can print the same record after saving. i have maked a report viewer which is print the data when we give the date and name. but i want print report currenty which saved.
i need i have a print button in form so i need when i click them it should print the current record which is i saved  currently.Â
i cannot retrieve the new identity value from an inserted record(via DataAdapter.Update) in my DataRow.
I'm using a strong typed Dataset as DAL. The table i want to update is joinded with other tables in the SelectCommand, hence the designer cannot automatically generate the insert-/update-/delete-commands and also it cannot "Refresh the DataTable" automatically. [URL]
I've tried to set AutoIncrement=true/false on the primary-key's DataColumn but the result is the same: last MAX-ID+1 instead of the actual ID the database generated(SQL-Server 2005 EP; pk datatype:int, Is identity:yes, Identity Increment:1).
This will be the wrong value f.e if another instance of the application inserted a record that the first instance yet not knows and therefore generates an ID that already exists.
To retrieve the new identity from db i've appended following to my insert-command's CommandText:
;SELECT CAST (SCOPE_IDENTITY() AS int) AS newIdRMA
Also i've tried to add an Output-Parameter to it's parameter-collection:
This is part of my code that updates the database and sets the new ID(that doesn't work):
[code]...
I need to get the identity (scope_identity) value of the newly inserted record. I don't see a way to do this.
I'm using
[Code]....
I am trying to get the identity column on which the record is inserted but i couldn't using stored procedure
see
[Code]....
My Code Using ASP.NET C# i am trying to display the identity in textbox
[Code]....
This would seem to be quite a trivial task, however I am having trouble retrieving the identity of the record inserted using the detailsview.insert() in the code behind. It would seem that detailsview.DataKey.Value would contain this value, but it is null after the insert is performed.
View 4 RepliesI am in a serious trouble right now, i wanted to know that how to write a query in LINQ to SQL to retrieve identity column's current value before inserting any value.
I need this cos i m building a windows app n i need to display this value before inserting a record. I have tried DataContext.ExecuteCommand('DBCC CHECKIDENT (Tablename)') but it returns the number of rows modified.
How do I set my insert identity return value parameter in codebehind? I have working code now but i have all of my parameters set in codebehindexcept the following:
[Code]....
I am using paging to my gridview (pagesize=4) . now i am in (X) page and i want to get (X+1) page top record or (X-1)page bottom record , how i can get .
View 2 RepliesI have a delete button bellow my gridview and I want a pop up to show when no record is selected and tell the user to first select a record. The button click event would show the pop up, but my gridview data blanks out.
Here is my code:
[Code]....
I'm very new on VWD, but I got the hang of it for the past 2 weeks(thank you for all the videos posted here in ASP.NET),but I'm really weak on the coding part(vb & c#),except for all the sample shown on the tutorials. Anyways, I have a simple project that
does insert, update & delete to SQL express using the details view. But to complete my project, I need to add a button that will create an event to restore the very last record inserted in SQL and display it back into the details view for minor modification
and nserted again as the newest record with the mod. I'm doing this so user, doesn't need to re-key-in redundant information, like names, original date & time etc, and just make modification on the description of the last record.....
I am counting from a table for that i have written code as below
protected void get_Id_Afterpoint()
{
int counter = 0;
string strSql = "select count(*) as ID from tblEnergy where ID=?";
OdbcCommand com = new OdbcCommand(strSql, con);
com.Parameters.AddWithValue("ID", DropDownList1.SelectedValue);
OdbcDataAdapter oda = new OdbcDataAdapter(com);
DataTable dt = new DataTable();
oda.Fill(dt);
if (dt.Rows.Count == 0)
{
lblID2.Text = "1";
}
else
{
counter = dt.Rows.Count;
counter = counter + 1;
lblID2.Text = Convert.ToString(counter);
}
}
there is no record related to DropDownList1.SelectedValue. but as i am counting if(dt.rows.count) and i put break point on the bolded part it shows 1 record. how it can be possible?
I want users to select a record in the GridView and then have that record open up in the Detailsview. How would I go about getting these two tools to communicate?
View 4 Repliesi have design a web application having suppliers table using SqlDatasource..
i have a master page in my design and other form are bound to a context menu..
Now i have displayed the records in the gridview..all i wanted is after i select a record in the gridview it will display the selected record in detailview from another aspx form..
i was able to create the link to another aspx form but the data that it display is the first data from the gridview not the data that i select.
i have one parent grid on which if user clicks a record ,the child details should get displayed on same page.
for example :
There is one department details table and employees table:
if user selects a record in department details grid,then employees in the selected department should get displayed in the next grid in the same page
How to Call a record on datalist by button click and display record on formview in model using Username
Here is what i tried
 <asp:DataList ID="GetMergedAll." runat="server">
<asp:Label ID="Name" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Post" runat="server" Text="Label"></asp:Label>
<asp:LinkButton ID="LinkButton6" runat="server">LinkButton</asp:LinkButton>
</asp:DataList>
protected void Page_Load(object sender, EventArgs e)
[Code] ....
HTML
 model here
<asp:FormView ID="Post" runat="server">
<asp:Label ID="Name" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Post" runat="server" Text="Label"></asp:Label>
</asp:FormView>
I was Make code to select top 3 record from db and I wont to enter every record in label or textbox
[Code]....
I am creating an album using the following stored procedure, which returns the primary key for the newly created record:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[fpa_sp_albums_update_insert]
@album_id int,
@album_name nvarchar (50),
@album_descr nvarchar(250),
@album_img_cover_id_FK int,
@album_creation_date date
AS
If @album_id > 0
UPDATE [fpa_albums]
SET
album_name=@album_name,
album_descr= @album_descr,
album_img_cover_id_FK = @album_img_cover_id_FK,
album_creation_date = @album_creation_date
Where ((album_id = @album_id))
Else
INSERT INTO [fpa_albums] (
album_name,
album_descr,
album_img_cover_id_FK,
album_creation_date)
VALUES (
@album_name,
@album_descr,
@album_img_cover_id_FK,
@album_creation_date)
Return SCOPE_IDENTITY();
I execute the above stored procedure using the SQLHELPER. The VB.NET code for the page is as follows:
[Code]....
However, the createdAlbumID always shows -1 instead of the id for the newly created album.
In IIS Manager center pane, there is an icon titled "Authentication" as follows: Clicking the icon, we get 3 items as follows: Right clicking the Anonymous Authentication and select edit, we have: Question: which one should I use? What is the difference?
View 3 RepliesI'm using a details view and a sqldatasource control to populate it. Every once in a while i get an error message because more than one row is returned. How can I have the data display in a gridview instead if more than one row is returned?
View 1 RepliesI have the following code, for testing im just writing the list to the page, but noticed that its missing the first record from the results. When i execute the procedures on the database, they return the correct values, so i know that part is working, the
next part is for records that should be returning 1 record, the arraylist is empty, even though it should return1 record. What am i doing wrong with the code below? ( gratssec is a class that contains the procedures we are using.
[Code]....
I have a website where i already have User / Roles mechanism. What i am after is the if user update certain record i will include his username against that record thats easy enough. But if that row have multiple coulmns i want to save which coulmn he/she updated?How can i compare old and new data have save this information?
View 3 Replies