3 Replies - 3366 Views - Last Post: 26 March 2013 - 12:11 AM Rate Topic: -----

#1 christian Mukeba  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 96
  • Joined: 06-September 12

Tool strip Menu item

Posted 18 March 2013 - 01:02 AM

Hi everyone,

Can anyone hlp me here;
i have a form like this:
on the menu strip i have NEW and under new i have customers and what i want is when the user click on customers i want a empty customer GUI where the user can enter a new customer
Here's what i have done:
 Private Sub CustomerToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerToolStripMenuItem1.Click
        Dim DBCon As New SqlClient.SqlConnection(My.Settings.NewEvapcoDBConnectionString.ToString())
        Dim inc As Integer

        If inc <> -1 Then
            Dim dsNewRow As DataRow
            Dim ds As New CustomerDataSet

            dsNewRow = ds.Tables("Customers").NewRow

            dsNewRow.Item("CompanyName") = CustomerForm.CompanyNameTextBox.Text
            dsNewRow.Item("OldName") = CustomerForm.OldNameTextBox.Text
            dsNewRow.Item("PostalAddress") = CustomerForm.PostalAddressTextBox.Text
            dsNewRow.Item("Pocity") = CustomerForm.PoCityTextBox.Text
            dsNewRow.Item("PoPostalCode") = CustomerForm.PoPostalCodeTextBox.Text
            dsNewRow.Item("PhysicalAddress") = CustomerForm.PhysicalAddressTextBox.Text
            dsNewRow.Item("PhCity") = CustomerForm.PhysicalAddressTextBox.Text
            dsNewRow.Item("PhPostalCode") = CustomerForm.PhPostalCodeTextBox.Text
            dsNewRow.Item("Telephone") = CustomerForm.TelephoneTextBox.Text
            dsNewRow.Item("FaxNumber") = CustomerForm.FaxNumberTextBox.Text
            dsNewRow.Item("EmailAddress") = CustomerForm.EmailAddressTextBox.Text
            dsNewRow.Item("WebSite") = CustomerForm.WebSiteTextBox.Text
            ' dsNewRow.Item("LastTransaction") = CustomerForm.LastTransactionDateTimePicker
            dsNewRow.Item("DebtorsAccountNumber") = CustomerForm.DebtorsAccountNumberTextBox.Text
            dsNewRow.Item("Discount") = CustomerForm.DiscountTextBox.Text
            dsNewRow.Item("VATNo") = CustomerForm.VATNoTextBox.Text
            dsNewRow.Item("Bank") = CustomerForm.BankTextBox.Text
            dsNewRow.Item("Branch") = CustomerForm.BranchTextBox.Text
            dsNewRow.Item("BranchCode") = CustomerForm.BranchCodeTextBox.Text
            dsNewRow.Item("AccountNo") = CustomerForm.AccountNoTextBox.Text
            dsNewRow.Item("BEEStatus") = CustomerForm.BEEStatusTextBox.Text
            dsNewRow.Item("PaymentTerms") = CustomerForm.PaymentTermsTextBox.Text

            ds.Tables("Customers").Rows.Add(dsNewRow)


        End If
  End Sub

and i am getting an error saying customerID (PK) cannot allow null, how can i bypass that

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Tool strip Menu item

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3517
  • View blog
  • Posts: 12,008
  • Joined: 12-December 12

Re: Tool strip Menu item

Posted 18 March 2013 - 02:30 AM

Quote

and i am getting an error saying customerID (PK) cannot allow null, how can i bypass that

"bypass" is not really the right term to use :whistling: "correct" would be more appropriate.

I assume that CustomerID should be an auto-number (also called auto-increment or counter)? In your definition of CustomerDataSet:

CustomerIDColumn.AutoIncrement = True

There is also AutoIncrementSeed and AutoIncrementStep.

.. and, yes, a primary key value cannot be null/empty.
Was This Post Helpful? 0
  • +
  • -

#3 christian Mukeba  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 96
  • Joined: 06-September 12

Re: Tool strip Menu item

Posted 18 March 2013 - 02:43 AM

Yes you right the CustomerID is an auto-increment column and yes i have set my the auto increment property to true.
now my request is i want the user to have a new customer GUI where he can enter customer Infos, its exactly the same as having a bindingNavigatorAddNewItem
Was This Post Helpful? 0
  • +
  • -

#4 christian Mukeba  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 96
  • Joined: 06-September 12

Re: Tool strip Menu item

Posted 26 March 2013 - 12:11 AM

I've set the CustomerID to auto-increment but now nothing is happening the customer form is not even showing anymor what might be the problem?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1