Appened... I assume that I would simply query (SELECT) the existing notes then do an UPDATE fuction which would contain the existing notes + the new notes.... Correct??? Or is there another way of doing this?
Thanks
T
Why we are on the subject of UPDATING.... I do have one other problem... not related to the one above.
Curently I'm trying to perform an UPDATE to existing record. When the user clicks update I am not getting any errors (Even when I'm in Debug mode) but yet the data is not getting updated.
Am I missing somthing?
Many Thanks !!!!!
Here is my current code:
Protected Sub bUpdateSlsNum_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bUpdateSlsNum.Click
Dim myCommand As SqlCommand
Dim myConnection As SqlConnection
myConnection = New SqlConnection("Server=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|CustomerInfo.mdf;Integrated Security=True;User Instance=True")
Dim UpdateCmd As String = "UPDATE CustomerSalesNum SET WorkSheetID = @WorkSheetID, Price = @Price, Freight = @Freight, Setup = @Setup, " _
& "Injection = @Injection, Wheels = @Wheels, Security = @Security, SubTotal = @SubTotal, DocFee = @DocFee, TradeInAllow = @TradeInAllow, TaxAmount = @TaxAmount, SalesTax = @SalesTax, " _
& "TradeLienBal = @TradeLienBal, Other = @Other, PAQuote = @PAQuote, TitleFee = @TitleFee, DownPay = @DownPay, Total = @Total WHERE [WorkSheetID]= '" & "@" & lblRWorkSheetID.Text & "'"
myCommand = New SqlCommand(UpdateCmd, myConnection)
myCommand.Parameters.Add(New SqlParameter("@WorkSheetID", Data.SqlDbType.NVarChar))
myCommand.Parameters("@WorkSheetID").Value = lblRWorkSheetID.Text
myCommand.Parameters.Add(New SqlParameter("@Price", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Price").Value = tbUPPRice.Text
myCommand.Parameters.Add(New SqlParameter("@Freight", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Freight").Value = tbUPFreight.Text
myCommand.Parameters.Add(New SqlParameter("@Setup", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Setup").Value = tbUPSetup.Text
myCommand.Parameters.Add(New SqlParameter("@Injection", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Injection").Value = tbUPInjection.Text
myCommand.Parameters.Add(New SqlParameter("@Wheels", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Wheels").Value = tbUPWheels.Text
myCommand.Parameters.Add(New SqlParameter("@Security", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Security").Value = tbUPFactorySec.Text
myCommand.Parameters.Add(New SqlParameter("@SubTotal", Data.SqlDbType.NVarChar))
myCommand.Parameters("@SubTotal").Value = tbUPSUBT.Text
myCommand.Parameters.Add(New SqlParameter("@DocFee", Data.SqlDbType.NVarChar))
myCommand.Parameters("@DocFee").Value = tbUPDOCFee.Text
myCommand.Parameters.Add(New SqlParameter("@TradeInAllow", Data.SqlDbType.NVarChar))
myCommand.Parameters("@TradeInAllow").Value = tbUPTIA.Text
myCommand.Parameters.Add(New SqlParameter("@TaxAmount", Data.SqlDbType.NVarChar))
myCommand.Parameters("@TaxAmount").Value = tbUPTAX.Text
myCommand.Parameters.Add(New SqlParameter("@SalesTax", Data.SqlDbType.NVarChar))
myCommand.Parameters("@SalesTax").Value = tbUPSALETAX.Text
myCommand.Parameters.Add(New SqlParameter("@TradeLienBal", Data.SqlDbType.NVarChar))
myCommand.Parameters("@TradeLienBal").Value = tbUPTILB.Text
myCommand.Parameters.Add(New SqlParameter("@Other", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Other").Value = tbUPOther.Text
myCommand.Parameters.Add(New SqlParameter("@PAQuote", Data.SqlDbType.NVarChar))
myCommand.Parameters("@PAQuote").Value = tbUPPAQuote.Text
myCommand.Parameters.Add(New SqlParameter("@TitleFee", Data.SqlDbType.NVarChar))
myCommand.Parameters("@TitleFee").Value = tbUPTitle.Text
myCommand.Parameters.Add(New SqlParameter("@DownPay", Data.SqlDbType.NVarChar))
myCommand.Parameters("@DownPay").Value = tbUPDownPay.Text
myCommand.Parameters.Add(New SqlParameter("@Total", Data.SqlDbType.NVarChar))
myCommand.Parameters("@Total").Value = LBLUTOTAL.Text
myCommand.Connection.Open()
Try
myCommand.ExecuteNonQuery()
ShowMessageBox(Me, "ATTENTION: Customer Data has been Updated.")
bUpdateSlsNum.Enabled = False
Catch ex As SqlException
If ex.Number = 2627 Then
ShowMessageBox(Me, "ERROR: A record already exists with " _
& "the same primary key")
Else
ShowMessageBox(Me, "ERROR: Could not add record")
End If
End Try
myCommand.Connection.Close()
MVMain.ActiveViewIndex = -1
DVSALESNUMBERS.
End Sub