Click here to Skip to main content
14,976,940 members
Home / Discussions / C#
   

C#

 
Generaladd DISTINCT drop PARALLEL Pin
Luc Pattyn2-Mar-20 0:48
sitebuilderLuc Pattyn2-Mar-20 0:48 
Generaldrop TOLIST, avoid memory stress Pin
Luc Pattyn2-Mar-20 9:13
sitebuilderLuc Pattyn2-Mar-20 9:13 
AnswerRe: Igroupping with Parallel Pin
Eddy Vluggen1-Mar-20 13:47
professionalEddy Vluggen1-Mar-20 13:47 
GeneralRe: Igroupping with Parallel Pin
Member 110035101-Mar-20 22:18
MemberMember 110035101-Mar-20 22:18 
QuestionError must declare scalar variable @ISBN update statement c# Pin
Member 1164145429-Feb-20 5:20
MemberMember 1164145429-Feb-20 5:20 
AnswerRe: Error must declare scalar variable @ISBN update statement c# Pin
OriginalGriff29-Feb-20 5:38
mveOriginalGriff29-Feb-20 5:38 
GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
Member 1164145429-Feb-20 22:20
MemberMember 1164145429-Feb-20 22:20 
GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
OriginalGriff29-Feb-20 22:42
mveOriginalGriff29-Feb-20 22:42 
That's because you are adding the parameters to the previous cmd instance - you create the new SqlCommand object after you add the parameters and their values.
Try this:

using (con = new SqlConnection(ConnectionString))
   {
   con.Open();

   string cmd_query = "UPDATE book_tbl SET Type_ID = @cmbtyp, category = @cmbcat, title = @title, publisher_ID = @cmbpub, A_ID = @cmbauthor, first_name = @fname, last_name = @lname, publication = @pub WHERE ISBN = @isbn";
   using (cmd = new SqlCommand(cmd_query, con))
      {
      cmd.Parameters.AddWithValue("@cmbtyp", cmbtyp.Text);
      cmd.Parameters.AddWithValue("@cmbcat", cmbcat.Text) ;
      cmd.Parameters.AddWithValue("@title", txtTitle.Text);
      cmd.Parameters.AddWithValue("@cmbpub", cmbpub.Text) ;
      cmd.Parameters.AddWithValue("@cmbauthor", cmbauthor.Text);
      cmd.Parameters.AddWithValue("@fname",txtfname.Text );
      cmd.Parameters.AddWithValue("@lname", txtlname.Text);
      cmd.Parameters.AddWithValue("@pub",txtpub.Text ) ;
      cmd.Parameters.AddWithValue("@isbn",  txtISBN.Text);
      cmd.ExecuteNonQuery();
      }
  }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
phil.o29-Feb-20 22:44
mvephil.o29-Feb-20 22:44 
QuestionESENTUTL in C# Pin
colins528629-Feb-20 4:28
Membercolins528629-Feb-20 4:28 
AnswerRe: ESENTUTL in C# Pin
OriginalGriff29-Feb-20 5:40
mveOriginalGriff29-Feb-20 5:40 
AnswerRe: ESENTUTL in C# Pin
Luc Pattyn29-Feb-20 9:27
sitebuilderLuc Pattyn29-Feb-20 9:27 
AnswerRe: ESENTUTL in C# Pin
Dave Kreskowiak29-Feb-20 10:38
mveDave Kreskowiak29-Feb-20 10:38 
AnswerRe: ESENTUTL in C# Pin
colins52861-Mar-20 22:50
Membercolins52861-Mar-20 22:50 
GeneralRe: ESENTUTL in C# Pin
Richard Deeming1-Mar-20 23:49
mveRichard Deeming1-Mar-20 23:49 
GeneralRe: ESENTUTL in C# Pin
colins52862-Mar-20 6:48
Membercolins52862-Mar-20 6:48 
GeneralRe: ESENTUTL in C# Pin
Richard Deeming2-Mar-20 7:08
mveRichard Deeming2-Mar-20 7:08 
AnswerRe: ESENTUTL in C# Pin
Mc_Topaz3-Mar-20 21:48
MemberMc_Topaz3-Mar-20 21:48 
QuestionNeed to Change DatagridView POP background color from Vincenzo Rossi Pin
Member 1464144527-Feb-20 17:25
MemberMember 1464144527-Feb-20 17:25 
AnswerRe: Need to Change DatagridView POP background color from Vincenzo Rossi Pin
Pete O'Hanlon27-Feb-20 20:30
mvePete O'Hanlon27-Feb-20 20:30 
AnswerRe: Need to Change DatagridView POP background color from Vincenzo Rossi Pin
OriginalGriff27-Feb-20 20:33
mveOriginalGriff27-Feb-20 20:33 
QuestionOutlookaddin Pin
Member 1475442324-Feb-20 19:26
MemberMember 1475442324-Feb-20 19:26 
AnswerRe: Outlookaddin Pin
OriginalGriff24-Feb-20 20:28
mveOriginalGriff24-Feb-20 20:28 
GeneralRe: Outlookaddin Pin
Member 1475442324-Feb-20 22:01
MemberMember 1475442324-Feb-20 22:01 
GeneralRe: Outlookaddin Pin
OriginalGriff24-Feb-20 22:16
mveOriginalGriff24-Feb-20 22:16 

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.