09-04-16, 09:16 AM
المشكلة تكون في موقع التخزين البيانات
المشكلة ظهرت في البرنامج :
الاكواد لتتخزين او حفظ البيانات :
ماهو الخطأ بالضبط رغم ان هذا الكود شغال قبل 100% وبعد التحديث البرنامج ظهرت لي هذا الخطأ
المشكلة ظهرت في البرنامج :
كود :
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.OleDb.OleDbException (0x80004005): The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Rent_Schedule.Form5.Button1_Click(Object sender, EventArgs e) in E:\my project\Complete Project\Rent Schedule\Rent Schedule\Form5.vb:line 60
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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1073.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Rent Schedule
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/my%20project/Complete%20Project/Rent%20Schedule/Rent%20Schedule/bin/Debug/Rent%20Schedule.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 10.0.0.0
Win32 Version: 14.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1068.2 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1064.2 built by: NETFXREL3STAGE
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
AccessToAccess
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/my%20project/Complete%20Project/Rent%20Schedule/Rent%20Schedule/bin/Debug/AccessToAccess.DLL
----------------------------------------
Microsoft.ReportViewer.WinForms
Assembly Version: 12.0.0.0
Win32 Version: 12.0.2402.20
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms/12.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.WinForms.dll
----------------------------------------
System.Data.DataSetExtensions
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1038.0 built by: NETFXREL2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
Microsoft.ReportViewer.Common
Assembly Version: 12.0.0.0
Win32 Version: 12.0.2402.20
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.ReportViewer.Common/12.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.Common.dll
----------------------------------------
Microsoft.SqlServer.Types
Assembly Version: 12.0.0.0
Win32 Version: 2014.0120.2000.08 ((SQL14_RTM).140220-1752)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.SqlServer.Types/12.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Types.dll
----------------------------------------
Microsoft.ReportViewer.ProcessingObjectModel
Assembly Version: 12.0.0.0
Win32 Version: 12.0.2402.20
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.ReportViewer.ProcessingObjectModel/12.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.ProcessingObjectModel.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
الاكواد لتتخزين او حفظ البيانات :
كود :
Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database1.accdb;Persist Security Info=False;")
conn.Open()
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells(0).Value Is Nothing Then Exit For
Dim sql As String =
"INSERT INTO [Rent]" &
"( Cus_ID, Cus_Name, Cus_Private_Number, Cus_Address, Cus_Car, Cus_Telephone_Number, Cus_Balance, Equ_Name, Equ_Price, Equ_Qantity, Rent_Date )" &
"VALUES" &
"( @Cus_ID, @Cus_Name, @Cus_Private_Number, @Cus_Address, @Cus_Car, @Cus_Telephone_Number, @Cus_Balance, @Equ_Name, @Equ_Price, @Equ_Qantity, @Rent_Date )"
Using cmd As New OleDbCommand(sql, conn)
cmd.Parameters.AddWithValue("@Cus_ID", ComboBox1.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Name", TextBox1.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Private_Number", TextBox2.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Address", TextBox3.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Car", TextBox4.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Telephone_Number", TextBox5.Text.ToString)
cmd.Parameters.AddWithValue("@Cus_Balance", TextBox6.Text.ToString)
cmd.Parameters.AddWithValue("@Equ_Name", row.Cells(0).Value.ToString)
cmd.Parameters.AddWithValue("@Equ_Price", row.Cells(1).Value.ToString)
cmd.Parameters.AddWithValue("@Equ_Qantity", row.Cells(2).Value.ToString)
cmd.Parameters.AddWithValue("@Rent_Date", DateTimePicker1.Value.ToString)
cmd.ExecuteNonQuery()
End Using
Next
conn.Close()
End Using
MessageBox.Show("We have been successfully Date", "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub