-
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?
-
Can you show us ur coding and table structure?
-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks