NoNullAllowedException


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: NoNullAllowedException

  1. #1
    Join Date
    Mar 2006
    Posts
    29

    NoNullAllowedException

    i have created a form in VB.Net that stores data into an SQL DB. However, I run the app and fill in the data. Im pretty sure that I fill in the whole form, but this error occurs. I've got a Patient_ID_PK and Reg_Date which are filled in automatically.

    System.Data.NoNullAllowedException was unhandled
    Message="Column 'Name' does not allow nulls."
    Can someone please help me?

  2. #2
    Join Date
    Dec 2004
    Posts
    717
    Can you show us ur coding and table structure?
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  3. #3
    Join Date
    Mar 2006
    Posts
    29
    Hiya, this piece of code is supposed to bind the dataset to the database.

    Private Sub PatientBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PatientBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.PatientBindingSource.EndEdit()

    Dim newPatientRow As DatabaseDataSet.PatientRow
    newPatientRow = Me.DatabaseDataSet.Patient.NewPatientRow()

    Me.DatabaseDataSet.Patient.Rows.Add(newPatientRow)
    Me.PatientTableAdapter.Update(Me.DatabaseDataSet.Patient)

    Dim rowsAffected As Integer = 0
    rowsAffected = PatientTableAdapter.Update(DatabaseDataSet.Patient)
    MessageBox.Show(rowsAffected)

    End Sub
    This is the patient structure

    Patient

    Patient_No integer(8)
    Registration Date datetime
    Name string(10)
    Surname string(15)
    Address string(50)
    Post_Box string(5)
    Phone integer(8)
    Mobile integer(8)
    Email string(20)
    Date_of_Birth string(8)
    Blood_Type string(3)
    Patrient_Type boolean
    Next_of_Kin_Rel string(10)
    Name string(10)
    thanks for the help

  4. #4
    Join Date
    Dec 2004
    Posts
    717
    Dim newPatientRow As DatabaseDataSet.PatientRow
    newPatientRow = Me.DatabaseDataSet.Patient.NewPatientRow()
    Plz check whether there is any record included in this datarow "newPatientRow" or not.

    and check whether all fields of "Patient" Table allows NULL or not.

    Check it out this link
    http://www.homeandlearn.co.uk/NET/nets12p10.html
    Code:
     If inc <> -1 Then
    
    Dim cb As New OleDb.OleDbCommandBuilder(da)
    Dim dsNewRow As DataRow
    
    dsNewRow = ds.Tables("AddressBook").NewRow()
    
    dsNewRow.Item("FirstName") = txtFirstName.Text
    dsNewRow.Item("Surname") = txtSurname.Text
    
    ds.Tables("AddressBook").Rows.Add(dsNewRow)
    
    da.Update(ds, "AddressBook")
    
    MsgBox("New Record added to the Database")
    
    btnCommit.Enabled = False
    btnAddNew.Enabled = True
    btnUpdate.Enabled = True
    btnDelete.Enabled = True
    
    End If
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  5. #5
    Join Date
    Mar 2006
    Posts
    29
    Patient_No integer(8)
    Registration Date datetime
    Name string(10)
    Surname string(15)
    Address string(50)
    Post_Box string(5)
    Phone integer(8)
    Mobile integer(8)
    Email string(20)
    Date_of_Birth string(8)
    Blood_Type string(3)
    Patrient_Type boolean
    Next_of_Kin_Rel string(10)
    Name string(10)
    only Patient_No does not allow Null, however, upon compilation and testing, it's telling me that Name does not allow Null. I'm pretty sure I'm entering a value for name tho, so I'm a bit confused now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center