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

Database

 
GeneralRe: ado.net connections and .dispose? Pin
Roger Alsing29-Aug-04 20:25
Roger Alsing29-Aug-04 20:25 
GeneralRe: ado.net connections and .dispose? Pin
Colin Angus Mackay30-Aug-04 1:27
Colin Angus Mackay30-Aug-04 1:27 
AnswerRe: ado.net connections and .dispose? Pin
Rocky Moore31-Aug-04 20:01
Rocky Moore31-Aug-04 20:01 
GeneralIdentity primary key Pin
Diego F.26-Aug-04 23:18
Diego F.26-Aug-04 23:18 
GeneralRe: Identity primary key Pin
David Salter26-Aug-04 23:28
David Salter26-Aug-04 23:28 
GeneralRe: Identity primary key Pin
Diego F.26-Aug-04 23:50
Diego F.26-Aug-04 23:50 
GeneralRe: Identity primary key Pin
David Salter27-Aug-04 1:12
David Salter27-Aug-04 1:12 
GeneralRe: Identity primary key Pin
Colin Angus Mackay27-Aug-04 1:33
Colin Angus Mackay27-Aug-04 1:33 
DECLARE @id int;
INSERT INTO aTable(name, age)
VALUES('Joe Bloggs', 21);
SELECT @id = @@IDENTITY;
INSERT INTO anotherTable(id, phone)
VALUES(@id, '212-555-2468');


If you are doing this from within an ASP.NET application then you can do something like
CREATE PROCEDURE InsertATable
(
    @name varchar(32),
    @age int
)
AS
INSERT INTO aTable(name, age)
VALUES('Joe Bloggs', 21);
SELECT @@IDENTITY as Id;
GO
SqlCommand cmd = new SqlCommand("InsertATable", connection);
cmd.Parameters.Add("@name", "Joe Bloggs");
cmd.Parameters.Add("@age", 21);
cmd.CommandType = CommandType.StoredProcedure;
int id = (int)cmd.ExecuteScalar();
// I now have the id of the newly created record in my .NET application.



Does this help?


"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!


GeneralSQL and the growing log file Pin
totig25-Aug-04 20:02
totig25-Aug-04 20:02 
GeneralRe: SQL and the growing log file Pin
mikasa26-Aug-04 3:40
mikasa26-Aug-04 3:40 
GeneralRe: SQL and the growing log file Pin
Mekong River26-Aug-04 3:41
Mekong River26-Aug-04 3:41 
GeneralRe: SQL and the growing log file Pin
totig26-Aug-04 3:47
totig26-Aug-04 3:47 
GeneralRe: SQL and the growing log file Pin
Rocky Moore31-Aug-04 20:18
Rocky Moore31-Aug-04 20:18 
GeneralNested Transaction between ADO.NET and T-SQL Pin
Sanjeev Kumar25-Aug-04 14:29
Sanjeev Kumar25-Aug-04 14:29 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
S Sansanwal25-Aug-04 16:33
S Sansanwal25-Aug-04 16:33 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Sanjeev Kumar25-Aug-04 16:46
Sanjeev Kumar25-Aug-04 16:46 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Colin Angus Mackay25-Aug-04 22:34
Colin Angus Mackay25-Aug-04 22:34 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Sanjeev Kumar26-Aug-04 7:07
Sanjeev Kumar26-Aug-04 7:07 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Colin Angus Mackay26-Aug-04 8:45
Colin Angus Mackay26-Aug-04 8:45 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Sanjeev Kumar26-Aug-04 13:59
Sanjeev Kumar26-Aug-04 13:59 
GeneralRe: Nested Transaction between ADO.NET and T-SQL Pin
Colin Angus Mackay27-Aug-04 6:07
Colin Angus Mackay27-Aug-04 6:07 
GeneralParse sql query without executing Pin
tocheng00525-Aug-04 11:42
susstocheng00525-Aug-04 11:42 
GeneralRe: Parse sql query without executing Pin
S Sansanwal25-Aug-04 16:31
S Sansanwal25-Aug-04 16:31 
GeneralRe: Parse sql query without executing Pin
tocheng00526-Aug-04 12:07
susstocheng00526-Aug-04 12:07 
GeneralDataSet with GUIDs Pin
mikasa25-Aug-04 11:21
mikasa25-Aug-04 11:21 

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.