Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# code is only inserting 1 record. Pin
Sascha Lefèvre25-Jun-15 14:25
professionalSascha Lefèvre25-Jun-15 14:25 
AnswerRe: C# code is only inserting a few records. Pin
Richard Deeming25-Jun-15 8:47
mveRichard Deeming25-Jun-15 8:47 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell25-Jun-15 9:16
Norris Chappell25-Jun-15 9:16 
GeneralRe: C# code is only inserting a few records. Pin
Richard Deeming25-Jun-15 9:29
mveRichard Deeming25-Jun-15 9:29 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell25-Jun-15 11:03
Norris Chappell25-Jun-15 11:03 
GeneralRe: C# code is only inserting a few records. Pin
Sascha Lefèvre25-Jun-15 14:08
professionalSascha Lefèvre25-Jun-15 14:08 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell25-Jun-15 15:20
Norris Chappell25-Jun-15 15:20 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell29-Jun-15 3:44
Norris Chappell29-Jun-15 3:44 
Richard,

I updated my sql query and it is giving me this error: (Must declare the scalar variable "@StaffTrackingID")

C#
protected void SubmitButton_Click(object sender, EventArgs e)
           {

               const string Query = "IF NOT EXISTS (SELECT StaffTrackingID, Period FROM StaffTrackingFTEData where StaffTrackingID = @StaffTrackingID and Period = @Period) INSERT INTO StaffTrackingFTEData ([StaffTrackingID], [EstimateHours], [EstimateFTE], [ActualHours], [ActualFTE],[Comment], [CommentBy], [Period]) VALUES ((Select StaffTracking.ID From StaffTracking where StaffTracking.CATWResourceName = @Name), @Estimatehours, @EstimateFTE, @ActualHours, @ActualFTE, @Comment, @CommentBy, @Period)";
               SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString);

               using (SqlCommand command = new SqlCommand(Query, conn))
               {
                   conn.Open();
                   command.Parameters.AddWithValue("@StaffTrackingID", SqlDbType.Int).Direction = ParameterDirection.Output;
                   foreach (GridViewRow row in gvCATW.Rows)
                   {


                       command.Parameters.AddWithValue("@Name", ((TextBox)row.FindControl("txtName")).Text);
                       command.Parameters.AddWithValue("@EstimateHours", ((TextBox)row.FindControl("txtEstimateHours")).Text);
                       command.Parameters.AddWithValue("@EstimateFTE", ((TextBox)row.FindControl("txtEstimateFTE")).Text);
                       command.Parameters.AddWithValue("@ActualHours", ((TextBox)row.FindControl("txtHours")).Text);
                       command.Parameters.AddWithValue("@ActualFTE", ((Label)row.FindControl("Label1")).Text);
                       command.Parameters.AddWithValue("@Comment", ((TextBox)row.FindControl("txtComment")).Text);
                       command.Parameters.AddWithValue("@CommentBy", ((TextBox)row.FindControl("txtCommentBy")).Text);
                       command.Parameters.AddWithValue("@Period", ((TextBox)row.FindControl("txtPeriod")).Text);


                       command.ExecuteNonQuery();
                       command.Parameters.Clear();
                   }
               }

           }

GeneralRe: C# code is only inserting a few records. Pin
Richard Deeming29-Jun-15 3:49
mveRichard Deeming29-Jun-15 3:49 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell29-Jun-15 4:42
Norris Chappell29-Jun-15 4:42 
GeneralRe: C# code is only inserting a few records. Pin
Richard Deeming29-Jun-15 4:44
mveRichard Deeming29-Jun-15 4:44 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell29-Jun-15 5:04
Norris Chappell29-Jun-15 5:04 
GeneralRe: C# code is only inserting a few records. Pin
PIEBALDconsult25-Jun-15 10:10
mvePIEBALDconsult25-Jun-15 10:10 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell25-Jun-15 10:35
Norris Chappell25-Jun-15 10:35 
GeneralRe: C# code is only inserting a few records. Pin
Sascha Lefèvre25-Jun-15 14:14
professionalSascha Lefèvre25-Jun-15 14:14 
GeneralRe: C# code is only inserting a few records. Pin
Norris Chappell25-Jun-15 15:49
Norris Chappell25-Jun-15 15:49 
GeneralRe: C# code is only inserting a few records. Pin
PIEBALDconsult29-Jun-15 15:36
mvePIEBALDconsult29-Jun-15 15:36 
QuestionFile permissions when writing a file to FTP server using FtpWebRequest Pin
DanDan_T25-Jun-15 6:47
DanDan_T25-Jun-15 6:47 
AnswerRe: File permissions when writing a file to FTP server using FtpWebRequest Pin
Pete O'Hanlon25-Jun-15 9:28
mvePete O'Hanlon25-Jun-15 9:28 
GeneralRe: File permissions when writing a file to FTP server using FtpWebRequest Pin
DanDan_T25-Jun-15 12:07
DanDan_T25-Jun-15 12:07 
GeneralRe: File permissions when writing a file to FTP server using FtpWebRequest Pin
DanDan_T26-Jun-15 5:29
DanDan_T26-Jun-15 5:29 
AnswerRe: File permissions when writing a file to FTP server using FtpWebRequest Pin
Brisingr Aerowing25-Jun-15 19:48
professionalBrisingr Aerowing25-Jun-15 19:48 
QuestionHOw to solve input string was not in the correct format Pin
Siao Da25-Jun-15 4:50
Siao Da25-Jun-15 4:50 
AnswerRe: HOw to solve input string was not in the correct format Pin
Pete O'Hanlon25-Jun-15 4:58
mvePete O'Hanlon25-Jun-15 4:58 
GeneralRe: HOw to solve input string was not in the correct format Pin
Siao Da25-Jun-15 5:08
Siao Da25-Jun-15 5:08 

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.