-
Jan 12th, 2015, 05:42 PM
#1
Thread Starter
Hyperactive Member
Logic Error or something else wrong?
using VB2010.
In the code below, if the NumSalesFound is greater than 0, the Customer file is updated correctly.
But, if the NumSalesFound is 0, the Customer file is not updated at all.
What am I doing wrong?
Problem Code:
Private Sub UpdateCustFileWithNewLastSaleInfo(ByRef NumSalesFound As Integer, ByRef HoldCustNum As Integer)
Try
Dim MyConnectionString As String = "Data Source=" & ModPrimaryServer _
& "\SqlExpress; Database=OlaDatabase; User Id=olaa; Password=tomcat;"
Me.CustomersTableTableAdapter1.Connection.ConnectionString = MyConnectionString
Me.CustomersTableTableAdapter1.Fill(Me.DeiDatabaseDataSet23.CustomersTable)
Dim CustFileIndex As Integer = Me.CustomersTableBindingSource1.Find("CCustomerNum", HoldCustNum)
If CustFileIndex > -1 Then
Me.CustomersTableBindingSource1.Position = CustFileIndex
If Integer.Parse(txtCNumVehsPurchased.Text) > 0 Then
txtCNumVehsPurchased.Text = ((Integer.Parse(txtCNumVehsPurchased.Text)) - 1).ToString
End If
If NumSalesFound > 0 Then ' NumSalesFound = the num of other Sales for this Cust(if any)
txtCLastSaleStkNum.Text = txtStkNum.Text
txtCLastSaleDate.Text = DateValue(txtVehSaleDte.Value)
dtpCLastSaleDte.Value = DateValue(txtVehSaleDte.Value)
txtCLastSaleFinLse.Text = ComboFinLse.Text
Else
txtCLastSaleStkNum.Text = ""
txtCLastSaleDate.Text = ""
dtpCLastSaleDte.Value = #2/2/2222#
txtCLastSaleFinLse.Text = ""
End If
Me.CustomersTableBindingSource1.EndEdit()
Me.CustomersTableTableAdapter1.Update(DeiDatabaseDataSet23.CustomersTable)
End If
Catch ex As Exception
Beep()
MsgBox("Error " & ex.Message)
End Try
End Sub
-
Jan 12th, 2015, 06:11 PM
#2
Re: Logic Error or something else wrong?
the Customer file is updated correctly
You really should know by now that those types of vague statements are not very help. What's not correct. What's happening or not happening?
That being said, I would put a break point a line 17 and check the value of NumSalesFound.
-
Jan 12th, 2015, 06:54 PM
#3
Thread Starter
Hyperactive Member
Re: Logic Error or something else wrong?
Thanks for the response. I have put a break point in the code; and the logic for both NumSalesFound > 0 and NumSalesFound = 0 are both executed correctly. The problem is that when the NumSalesFound = 0, the fields are not being changed to blank in the database; but remain unchanged to their previous values.
However, when the NumSalesFound > 0, the fields in the database are being changed to the values in my code properly.
And you are right, I really should know by now, and that is why I'm embarrassed to even have to ask this question!
Last edited by DexterRose; Jan 12th, 2015 at 07:46 PM.
-
Jan 12th, 2015, 10:03 PM
#4
Re: Logic Error or something else wrong?
I'm guessing that the textboxes are bound to customerstablebindingsource1. Have you put a break point inside the "else" to make sure it is entering there. Say line 23.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|