jampost
asked on
SQL Server 2008 database will not update in one of the tables included in a Visual Basic 2008 program written with Visual Studio 2008
I am trying to create a "new stored procedure" for Updating the database. This is my SQL Statement in the Table Adapter: (But, not working)
UPDATE EmpPayrollInfo
Set EmployeeNumber = @EmployeeNumber, EmpFirstName = @EmpFirstName, EmpLastName = @EmpLastName, HourlyAmount = @HourlyAmount, PieceRate = @PieceRate, Deductions_a = @Deductions_a, Deductions_b = @Deductions_b, Deductions_c = @Deductions_c, Deductions_d =@Deductions_d, Deductions_e = @Deductions_e, Fed_File_Married_Single = @Fed_File_Married_Single, Fed_Allowances = @Fed_Allowances, Fed_Extra_Withholding = @Fed_Extra_Withholding, AdvanceEarnedInc_Credit = @AdvanceEarnedInc_Credit, State_Allowances = @State_Allowances, State_File_Married_Single = @State_File_Married_Single , State_Extra_Withholding = @State_Extra_Withholding, County_PercentageRate = @County_PercentageRate, Notes = @Notes
Declare @EmployeeNumber varchar(50)
Declare @EmpFirstName varchar(50)
Declare @EmpLastName varchar(50)
Declare @HourlyAmount decimal(18, 2)
Declare @PieceRate Bit
Declare @Deductions_a decimal(18, 2)
Declare @Deductions_b decimal(18, 2)
Declare @Deductions_c decimal(18, 2)
Declare @Deductions_d decimal(18, 2)
Declare @Deductions_e decimal(18, 2)
Declare @Fed_File_Married_Single varchar(50)
Declare @Fed_Allowances Int
Declare @Fed_Extra_Withholding decimal(18, 2)
Declare @AdvanceEarnedInc_Credit Bit
Declare @State_Allowances Int
Declare @State_File_Married_Single varchar(50)
Declare @State_Extra_Withholding decimal(18, 2)
Declare @County_PercentageRate varchar(MAX)
Declare @Notes varchar(MAX)
UPDATE EmpPayrollInfo
Set EmployeeNumber = @EmployeeNumber, EmpFirstName = @EmpFirstName, EmpLastName = @EmpLastName, HourlyAmount = @HourlyAmount, PieceRate = @PieceRate, Deductions_a = @Deductions_a, Deductions_b = @Deductions_b, Deductions_c = @Deductions_c, Deductions_d =@Deductions_d, Deductions_e = @Deductions_e, Fed_File_Married_Single = @Fed_File_Married_Single, Fed_Allowances = @Fed_Allowances, Fed_Extra_Withholding = @Fed_Extra_Withholding, AdvanceEarnedInc_Credit = @AdvanceEarnedInc_Credit, State_Allowances = @State_Allowances, State_File_Married_Single = @State_File_Married_Single
Declare @EmployeeNumber varchar(50)
Declare @EmpFirstName varchar(50)
Declare @EmpLastName varchar(50)
Declare @HourlyAmount decimal(18, 2)
Declare @PieceRate Bit
Declare @Deductions_a decimal(18, 2)
Declare @Deductions_b decimal(18, 2)
Declare @Deductions_c decimal(18, 2)
Declare @Deductions_d decimal(18, 2)
Declare @Deductions_e decimal(18, 2)
Declare @Fed_File_Married_Single varchar(50)
Declare @Fed_Allowances Int
Declare @Fed_Extra_Withholding decimal(18, 2)
Declare @AdvanceEarnedInc_Credit Bit
Declare @State_Allowances Int
Declare @State_File_Married_Single
Declare @State_Extra_Withholding decimal(18, 2)
Declare @County_PercentageRate varchar(MAX)
Declare @Notes varchar(MAX)
what error do you get?
ASKER
Error: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
This is unaltered Navigator code in the VB 2008 program.
Public Class Payroll
Private Sub EmpPayrollInfoBindingNavig atorSaveIt em_Click(B yVal sender As System.Object, ByVal e As System.EventArgs) Handles EmpPayrollInfoBindingNavig atorSaveIt em.Click
Me.Validate()
Me.EmpPayrollInfoBindingSo urce.EndEd it()
Me.TableAdapterManager.Upd ateAll(Me. EmpPayInfo DataSet)
End Sub
This is unaltered Navigator code in the VB 2008 program.
Public Class Payroll
Private Sub EmpPayrollInfoBindingNavig
Me.Validate()
Me.EmpPayrollInfoBindingSo
Me.TableAdapterManager.Upd
End Sub
ASKER
Eyal,
Maybe I have incorrect syntax for declaring? I just got this error message when I tried to save changes in the table adapter.
Must declare the scalar variable “@EmployeeNumber”
Maybe I have incorrect syntax for declaring? I just got this error message when I tried to save changes in the table adapter.
Must declare the scalar variable “@EmployeeNumber”
ASKER
Exception Detail -- after trying to save during debug:
System.InvalidOperationExc
Message="Update requires a valid UpdateCommand when passed DataRow collection with modified rows."
Source="Starling Payroll"
StackTrace:
at Starling_Payroll.EmpPayInf
at Starling_Payroll.EmpPayInf
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.ToolS
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Scrol
at System.Windows.Forms.ToolS
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Nativ
at System.Windows.Forms.Unsaf
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at Starling_Payroll.My.MyAppl
at System.AppDomain._nExecute
at System.AppDomain.ExecuteAs
at Microsoft.VisualStudio.Hos
at System.Threading.ThreadHel
at System.Threading.Execution
at System.Threading.ThreadHel
InnerException:
ASKER
"Refresh the data table" at the table adapter is always unchecked. If you put a check in it, it will uncheck its self the second you leave it.
ASKER
This is the line that the error always points to:
Me.TableAdapterManager.Upd ateAll(Me. EmpPayInfo DataSet)
Me.TableAdapterManager.Upd
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Code Cruiser,
When I first read your comment, I was thinking "of cource I created a primary key. So I check anyway. I typed Primary Key in the first column and set it for Int, but........forgot to actually make it a primary key. Safe to say I will never make that mistake again. Thank you.
When I first read your comment, I was thinking "of cource I created a primary key. So I check anyway. I typed Primary Key in the first column and set it for Int, but........forgot to actually make it a primary key. Safe to say I will never make that mistake again. Thank you.
Glad to help :-)