TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tomas Westerlund
NA
38
32.6k
Get an OUTPUT variable from an Insert SQL statement
Nov 24 2012 1:53 PM
Hi,
I have been looking for away to get an output variable from an SQL query, however for SQL Compact Edition.
using (da.InsertCommand = new SqlCeCommand(@"INSERT INTO SCHEMAS (SCHEMA_NAME, FromMethod, ToMethod, ConnectedToUserID) OUTPUT INSERTED.SCHEMA_ID
VALUES (@SchemaName, @FromMethod, @ToMethod, @ConnectedToUserID)", connString))
{
da.InsertCommand.Parameters.AddWithValue("@SchemaName", textBoxSchemaName.Text);
da.InsertCommand.Parameters.AddWithValue("@FromMethod", comboBoxFromMethod.Text);
da.InsertCommand.Parameters.AddWithValue("@ToMethod", comboBoxToMethod.Text);
da.InsertCommand.Parameters.AddWithValue("@ConnectedToUserID", userID);
da.InsertCommand.Connection.Open(); //Needed to open a connection
da.InsertCommand.ExecuteNonQuery(); //Performs the actual SQL statement
this.Close();
}
Can someone please assist my how I can get this output variable out to a C# variable?
Thanks in advance,
Tomas
Reply
Answers (
2
)
Change all file names in specific folder
projects