Showing posts with label row. Show all posts
Showing posts with label row. Show all posts

Monday, March 26, 2012

How can I capture the id columne from a new datarow?

In my BLL I have a method that adds a new row to a table in the database...

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddContact(string firstname, string lastname, string middleinit, bool active, Guid uid, bool newsletter)
{
ContactsDAL.tblContactsDataTable contacts = new ContactsDAL.tblContactsDataTable();
ContactsDAL.tblContactsRow contact = contacts.NewtblContactsRow();

contact.FirstName = firstname;
contact.LastName = lastname;
contact.MiddleName = middleinit;
contact.Active = active;
contact.UserID = uid;
contact.Newletter = newsletter;

contacts.AddtblContactsRow(contact);
int rowsAffected = Adapter.Update(contact);

return rowsAffected == 1;
}

The primary key in this table is a BigInt set as an identity column...How do I capture the value of the primary key that gets created when the new row is added?

Hi,basically the new row that create will be updated with the ID of new inserted record.

However, the following sql piece:

Select SCOPE_IDENTITY()

will do it.

Cheers,

Yani

|||

Im familiar with the idea of SCOPE_IDENTITY but am not certain how to use it in a BLL.

How could I modify the code in my BLL method to retreive the SCOPE_IDENTITY?

|||

Basically, the designer does that for you.

For example the generated Insert statements looks like:

CREATEPROCEDURE [dbo].[AdministratorInsert]

(

@.AdministratorIdint,

@.AdministratorNamenvarchar(50),

@.Passwordnvarchar(50),

@.Activebit

)

AS

SETNOCOUNTOFF;

INSERTINTO [Administrator]([AdministratorId], [AdministratorName], [Password], [Active])VALUES(@.AdministratorId, @.AdministratorName, @.Password, @.Active);

SELECT AdministratorId, AdministratorName, Password, ActiveFROM AdministratorWHERE(AdministratorId= @.AdministratorId)

after a record is inserted , it is selected and the DataRow gots updated automatically.

sql

Wednesday, March 21, 2012

how can i add heading in Matrix Report for columns and rows

How can i add a column heading for coulumns and row heading for rows in Matrix report created by wizard. i m using vs 2005 ..You need to create a Row Group or Column Group but at least from my perspective I have always stayed from Matrix's in MS RS and the reason why is - I cannot control the extrapolation of the matrix to the defined width of my report - probably a lousy reason - but I "fake" out based on a regular table layout a matrix look and feel with drill through's...
If the user wants to see everything then "click" and everything will be displayed - but for the first panel of data I provide as much possible releavant info and you want to see more then click on a link and I will navigate you to eternity! Also, when I navigate I keep the primary data field they clicked on as a parm and display this in the subsequent (called module) so the have a "path" of wheer they started there "infinite journey" from!
Best regards,

How can i access internal row id of sql server

I want to access nth row from a table in sql server without use of
row_number(),rank() and even without top keyword.
May any one help me.
Please mail me the solution at khaleek_ahmad@.yahoo.com.> How can i access internal row id of sql server
What makes you think there is an internal row number in SQL? The key point
is a table is by definition an unordered set of rows. Retrieving a row by
ordinal position implies ordering and there are other issues as well. What
is the underlying reason that you need to select individual rows by row
number?
>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
If you must retrieve data by ordinal position, one method create a server
cursor based on a SELECT...ORDER BY and retrieve individual rows using
FETCH...ABSOLUTE. This can technique can have performance implications with
large tables, though.
--
Hope this helps.
Dan Guzman
SQL Server MVP
<khaleek_ahmad@.yahoo.com> wrote in message
news:1165316287.766901.82530@.16g2000cwy.googlegroups.com...
>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
> May any one help me.
> Please mail me the solution at khaleek_ahmad@.yahoo.com.
>

How can i access internal row id of sql server

I want to access nth row from a table in sql server without use of
row_number(),rank() and even without top keyword.
May any one help me.
Please mail me the solution at khaleek_ahmad@.yahoo.com.
> How can i access internal row id of sql server
What makes you think there is an internal row number in SQL? The key point
is a table is by definition an unordered set of rows. Retrieving a row by
ordinal position implies ordering and there are other issues as well. What
is the underlying reason that you need to select individual rows by row
number?

>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
If you must retrieve data by ordinal position, one method create a server
cursor based on a SELECT...ORDER BY and retrieve individual rows using
FETCH...ABSOLUTE. This can technique can have performance implications with
large tables, though.
Hope this helps.
Dan Guzman
SQL Server MVP
<khaleek_ahmad@.yahoo.com> wrote in message
news:1165316287.766901.82530@.16g2000cwy.googlegrou ps.com...
>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
> May any one help me.
> Please mail me the solution at khaleek_ahmad@.yahoo.com.
>

How can i access internal row id of sql server

I want to access nth row from a table in sql server without use of
row_number(),rank() and even without top keyword.
May any one help me.
Please mail me the solution at khaleek_ahmad@.yahoo.com.> How can i access internal row id of sql server
What makes you think there is an internal row number in SQL? The key point
is a table is by definition an unordered set of rows. Retrieving a row by
ordinal position implies ordering and there are other issues as well. What
is the underlying reason that you need to select individual rows by row
number?

>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
If you must retrieve data by ordinal position, one method create a server
cursor based on a SELECT...ORDER BY and retrieve individual rows using
FETCH...ABSOLUTE. This can technique can have performance implications with
large tables, though.
Hope this helps.
Dan Guzman
SQL Server MVP
<khaleek_ahmad@.yahoo.com> wrote in message
news:1165316287.766901.82530@.16g2000cwy.googlegroups.com...
>I want to access nth row from a table in sql server without use of
> row_number(),rank() and even without top keyword.
> May any one help me.
> Please mail me the solution at khaleek_ahmad@.yahoo.com.
>sql