Updating Data

ThomasM

Member
Joined
Apr 5, 2006
Messages
17
Programming Experience
Beginner
I have created a Table that contains a WorksheetID field and a SalesNotes field. I can successfully populate that table but I am uncertain as to how I can append to the SalesNotes Field.

I want to keep the orginal notes but populate addtional notes.

Would I do this by using the UPDATE call?

Many Thanks

T
 
It seems like you want to alter the datasource? If so, since you altering the datasource and not the dataset the answer will most likely depend on the type of datasource.
So what type of datasource are you working with (Access Database, Oracle, SQL Server, text file, ...)?
 
Details please

I'm still uncertain about what you're trying to do. Do you want to add a new field to contain the new notes or do you want to simply append the new notes on the end of the existing SalesNotes field?
 
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
 
Back
Top