index > Visual C# General > visual c# database

visual c# database

im getting this error when trying to run a form which saves details of a new user to the database. Please help its an emergency

System.Data.ConstraintException was unhandled
Message="Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
Source="System.Data"
StackTrace:
at System.Data.DataSet.FailedEnableConstraints()
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at Therapist.MusictherapistDataSetTableAdapters.TherapistTableAdapter.Fill(TherapistDataTable dataTable) in C:\Documents and Settings\tenille\My Documents\Visual Studio 2005\Projects\Musictherapist\Musictherapist\MusictherapistDataSet.Designer.cs:line 5042
at Therapist.NewUser.NewUser_Load(Object sender, EventArgs e) in C:\Documents and Settings\tenille\My Documents\Visual Studio 2005\Projects\Musictherapist\Musictherapist\NewUser.cs:line 21
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at Therapist.Startup.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\tenille\My Documents\Visual Studio 2005\Projects\Musictherapist\Musictherapist\Start.cs:line 26
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Therapist.Program.Main() in C:\Documents and Settings\tenille\My Documents\Visual Studio 2005\Projects\Musictherapist\Musictherapist\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

zootmastaflex

The problem is mentioned in the stack trace above:

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints"

Check to verify that you are inserting proper data into the database. One or more values being entered into the database are violating constraints.

- Perhaps you are entering a null value into a column that doesn't allow nulls.

- Perhaps you are entering a value into a column that is a foreign key but the value is not in the parent table.

- Perhaps the userid, email address, etc. of the user is supposed to be unique and you are entering in a userid, email address, etc. that already exists in the user table.

Try entering the same data in the database manually to understand the error better.

Regards,

Dave




David Hayden, MVP C#, http://davidhayden.com/blog/dave/
David Hayden
reply 2

You can use google to search for other answers

 

More Articles

• how to get total cpu usage
• Windows Service: Specified Service Already Exists
• DllImport and enumerations
• Compare 2 objects
• Images in DataGridView
• Deploying 2.0 Framework of an Intranet
• Menu usage in C#
• Query Commands
• How can I do MS Charts ?
• Can Window CE based application run for Windows XP?
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• How do I listen for File Downloads using
• use printdocument
• com addin help?
• How to: create an enumeration user setting
• How to get a page source code of URL pro
• Weird problem writing to custom Eventlog
• Joining Pics
• Overlay Graphics on Direct3D
• how to insert data to sql databse1.mdf?
• How can I make an pictureBox "Blink
• Disable double click on control
• How do I enable Drag Drop Events for the
• Using Type specific collections
• MIDL "module" statements and C
• information path is required

Hot Articles

• how can I deep clone an instance of any
• Is there a setting on the MS Exchange Se
• How to get the last line of a richtextbox
• DataGridView isn't showing all the rows
• Modify form attributes of the main app f
• ComboBox and dynamic DataSource !!
• Programtically determine paramaters
• "Child list for field 'Customer' ca
• Not Freeing Memory
• Graph component
• User Control functionality
• Is there a way to exclude some codes bei
• Passing Arguments to new form
• toolstripcombobox size in the toolbar
• Create Dataset Object from Schema (xsd)

Recommend Articles

• Bug or intentional: aspnet_Membership_Ge
• Hide Console Window in C# Console Applic
• Build exe with images from VS2003
• How to sign EXE using signtool with Veri
• Web Form - How to change the field value
• Using a recursive method with a Generic
• Folder compression
• edit textbox msword form c#
• web - file date modified
• insert java script
• Timer Interval Problem
• Windows Service - multiple instances
• Save an image wit GDI+
• xsl transform
• ArrayList into a DataGird?