By Neko

2012-02-16 21:43:10 8 Comments

Using C# in Visual Studio, I'm inserting a row into a table like this:

INSERT INTO foo (column_name)
VALUES ('bar')

I want to do something like this, but I don't know the correct syntax:

INSERT INTO foo (column_name)
VALUES ('bar')

This would return the foo_id column from the newly inserted row.

Furthermore, even if I find the correct syntax for this, I have another problem: I have SqlDataReader and SqlDataAdapter at my disposal. As far as I know, the former is for reading data, the second is for manipulating data. When inserting a row with a return statement, I am both manipulating and reading data, so I'm not sure what to use. Maybe there's something entirely different I should use for this?

Related Questions

Sponsored Content

42 Answered Questions

[SOLVED] How to return only the Date from a SQL Server DateTime datatype

47 Answered Questions

33 Answered Questions

[SOLVED] How do I UPDATE from a SELECT in SQL Server?

27 Answered Questions

[SOLVED] Get int value from enum in C#

  • 2009-06-03 06:46:39
  • jim
  • 1448741 View
  • 1738 Score
  • 27 Answer
  • Tags:   c# enums casting int

39 Answered Questions

22 Answered Questions

[SOLVED] What is the best way to give a C# auto-property an initial value?

30 Answered Questions

12 Answered Questions


Sponsored Content