Click here to Skip to main content
15,921,905 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: ReportViewer LocalReport does not render correctly Pin
Member 438223225-Mar-08 23:30
Member 438223225-Mar-08 23:30 
Questionwhat is an exception Pin
Member 470807720-Mar-08 2:57
Member 470807720-Mar-08 2:57 
GeneralRe: what is an exception Pin
eyeseetee20-Mar-08 3:05
eyeseetee20-Mar-08 3:05 
GeneralRe: what is an exception Pin
N a v a n e e t h20-Mar-08 3:06
N a v a n e e t h20-Mar-08 3:06 
Questionweb and windows Pin
Member 470807720-Mar-08 2:56
Member 470807720-Mar-08 2:56 
GeneralRe: web and windows Pin
eyeseetee20-Mar-08 3:05
eyeseetee20-Mar-08 3:05 
GeneralRe: web and windows Pin
Vasudevan Deepak Kumar20-Mar-08 3:17
Vasudevan Deepak Kumar20-Mar-08 3:17 
GeneralSQL2005 INSERT / IDENTITY help required Pin
munklefish20-Mar-08 2:21
munklefish20-Mar-08 2:21 
* Please note i have also posted this in SQL forum as i dont know which is most appropriate. If a mod feel it is wrongly placed here i appologise, feel free to delete.

Problem:

Hi,

I need help with an sql query please.

I wish to insert a new record into a table, and instantly retreive the new records id. Is it possible to do this in one sql statement rather than an INSERT followed by the SELECT statement?

My INSERT looks like this:

string conn = System.Configuration.ConfigurationManager.ConnectionStrings["artisanConnectionString"].ConnectionString;
SqlConnection uniqueCon = new SqlConnection(conn);
//set SQL statement
SqlCommand cmd = new SqlCommand("INSERT INTO [tbl_Additional] (add_Item, add_Price) VALUES ('" + TextBox10.Text + "', '" + TextBox11.Text + "') ", uniqueCon);
cmd.Connection.Open();
try
{//insert/ add new record
//commit to database
cmd.ExecuteNonQuery();
//clear form add/edit
TextBox10.Text = null;
TextBox11.Text = null;
//confirm to user
ShowMessageBox("New unique Item Added!");
//update dataset
GridView2.DataBind();
}
catch
{
ShowMessageBox("Unable to add record!!! Please try again later.");
}
cmd.Connection.Close();

Any help would be greatly appreciated.
Thanks & Happy Easter!
GeneralRe: SQL2005 INSERT / IDENTITY help required Pin
Vasudevan Deepak Kumar20-Mar-08 3:19
Vasudevan Deepak Kumar20-Mar-08 3:19 
GeneralGeneral How to get Connection.GetSchema("columns",restrictions) in order by ordinal position Pin
ashish bhakhar20-Mar-08 1:49
ashish bhakhar20-Mar-08 1:49 
GeneralRe: General How to get Connection.GetSchema("columns",restrictions) in order by ordinal position Pin
eyeseetee20-Mar-08 1:56
eyeseetee20-Mar-08 1:56 
QuestionDate Validation ...its very urgent***************************************** Pin
udaymohan20-Mar-08 1:05
udaymohan20-Mar-08 1:05 
GeneralRe: Date Validation ...its very urgent***************************************** Pin
Not Active20-Mar-08 1:07
mentorNot Active20-Mar-08 1:07 
GeneralRe: Date Validation ...its very urgent***************************************** Pin
eyeseetee20-Mar-08 1:16
eyeseetee20-Mar-08 1:16 
GeneralRe: Date Validation ...its very urgent***************************************** Pin
udaymohan20-Mar-08 1:23
udaymohan20-Mar-08 1:23 
GeneralRe: Date Validation ...its very urgent***************************************** Pin
eyeseetee20-Mar-08 1:30
eyeseetee20-Mar-08 1:30 
AnswerRe: Date Validation ...its very urgent* Pin
rahul.net1120-Mar-08 1:38
rahul.net1120-Mar-08 1:38 
GeneralRe: Date Validation ...its very urgent***************************************** Pin
Vasudevan Deepak Kumar20-Mar-08 3:20
Vasudevan Deepak Kumar20-Mar-08 3:20 
GeneralOpen Mulltiple Windows Pin
Devkranth Kishore Vanja20-Mar-08 1:03
Devkranth Kishore Vanja20-Mar-08 1:03 
GeneralRe: Open Mulltiple Windows Pin
Vasudevan Deepak Kumar20-Mar-08 21:42
Vasudevan Deepak Kumar20-Mar-08 21:42 
GeneralRe: Open Mulltiple Windows Pin
ashish bhakhar21-Mar-08 0:38
ashish bhakhar21-Mar-08 0:38 
GeneralPlease Help me. How to Validate 12 hour time format using ajax Pin
saravanan12july20-Mar-08 0:30
saravanan12july20-Mar-08 0:30 
QuestionFinding the KEYPRESS in ASP.NET with C# Pin
John Sundar20-Mar-08 0:20
John Sundar20-Mar-08 0:20 
GeneralRe: Finding the KEYPRESS in ASP.NET with C# Pin
eyeseetee20-Mar-08 0:37
eyeseetee20-Mar-08 0:37 
QuestionRe: Finding the KEYPRESS in ASP.NET with C# Pin
John Sundar20-Mar-08 0:55
John Sundar20-Mar-08 0:55 

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.