Click here to Skip to main content
15,900,907 members
Home / Discussions / Database
   

Database

 
GeneralRe: stored porcedure ? Pin
John_Adams20-Mar-08 23:39
John_Adams20-Mar-08 23:39 
GeneralRe: stored porcedure ? Pin
ashish bhakhar21-Mar-08 0:15
ashish bhakhar21-Mar-08 0:15 
GeneralRetrieve and change an Identity column value... Pin
anderslundsgard20-Mar-08 22:30
anderslundsgard20-Mar-08 22:30 
GeneralRe: Retrieve and change an Identity column value... Pin
N a v a n e e t h20-Mar-08 23:08
N a v a n e e t h20-Mar-08 23:08 
GeneralRe: Retrieve and change an Identity column value... Pin
anderslundsgard21-Mar-08 1:41
anderslundsgard21-Mar-08 1:41 
GeneralRe: Retrieve and change an Identity column value... Pin
N a v a n e e t h21-Mar-08 1:46
N a v a n e e t h21-Mar-08 1:46 
GeneralRe: Retrieve and change an Identity column value... Pin
anderslundsgard25-Mar-08 5:12
anderslundsgard25-Mar-08 5:12 
GeneralRe: Retrieve and change an Identity column value... Pin
ashish bhakhar21-Mar-08 0:27
ashish bhakhar21-Mar-08 0:27 
you can do this using two methods.

1) using sql server column identity property:
in this method, which column you want to give identity, open the table definition and right click on the field (which you want to be indent), set the identity specification - IsIdentity to 'yes' & Identity Increment and Identity seed to 1.

2) using c# in your asp.net page:

using asp.net page, first get the maximum record of the table using max(column name) using data reader & increment that value to 1 and assign that value to new inserted row.

for ex:
sqlconnection cn = new sqlconnection();
cn.open();
string str = "select max(userid) from user";
sqlcommand cmd = new sqlcommmand(str,cn);
idatareader rdr = cmd.executereader();
int id = 0;
if(rdr.read()==true)
{
id = rdr[0].tostring();
}
id = id+1;

now the id you will get is incremented id for inserting new query or row to table.
use this id and insert value of this id as the field of userid to insert new row.
GeneralSELECT SCOPE_IDENTITY() & INSERT Problems Pin
munklefish20-Mar-08 2:19
munklefish20-Mar-08 2:19 
GeneralRe: SELECT SCOPE_IDENTITY() & INSERT Problems Pin
Declan Bright20-Mar-08 2:36
Declan Bright20-Mar-08 2:36 
GeneralNeed sql query Pin
Exelioindia20-Mar-08 1:58
Exelioindia20-Mar-08 1:58 
QuestionHow to get Connection.GetSchema("columns",restrictions) in order by ordinal position Pin
ashish bhakhar20-Mar-08 1:27
ashish bhakhar20-Mar-08 1:27 
QuestionHow to get connection.schema("columns",restrictions) in order by ordinal position Pin
ashish bhakhar20-Mar-08 0:58
ashish bhakhar20-Mar-08 0:58 
AnswerRe: How to get connection.schema("columns",restrictions) in order by ordinal position Pin
Mark J. Miller20-Mar-08 11:06
Mark J. Miller20-Mar-08 11:06 
GeneralRe: How to get connection.schema("columns",restrictions) in order by ordinal position Pin
ashish bhakhar20-Mar-08 19:57
ashish bhakhar20-Mar-08 19:57 
Generaldata tables for a job site Pin
AbhishekAgarwal1519-Mar-08 22:04
AbhishekAgarwal1519-Mar-08 22:04 
GeneralRe: data tables for a job site Pin
Ashfield19-Mar-08 22:43
Ashfield19-Mar-08 22:43 
GeneralRe: data tables for a job site Pin
Pete O'Hanlon22-Mar-08 9:31
mvePete O'Hanlon22-Mar-08 9:31 
GeneralRe: data tables for a job site Pin
KrisnNala25-Mar-08 9:09
KrisnNala25-Mar-08 9:09 
QuestionOCP Pin
KambojR19-Mar-08 21:56
KambojR19-Mar-08 21:56 
GeneralRe: OCP Pin
Ashfield20-Mar-08 3:20
Ashfield20-Mar-08 3:20 
Questionhow do I use sql triggers to replicate update changes across two different databases Pin
GDMFSOB19-Mar-08 20:56
GDMFSOB19-Mar-08 20:56 
GeneralRe: how do I use sql triggers to replicate update changes across two different databases Pin
andyharman20-Mar-08 0:26
professionalandyharman20-Mar-08 0:26 
AnswerRe: how do I use sql triggers to replicate update changes across two different databases Pin
GDMFSOB20-Mar-08 1:58
GDMFSOB20-Mar-08 1:58 
Generallooping in SQL Server2005 Pin
salon19-Mar-08 20:32
salon19-Mar-08 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.