none
Fill Datareader Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints RRS feed

  • Question

  • Hi,
    Well I have datareader wish I am trying to load it into the datatable

    MyTable.load(MyReader)

    when I am  trying to do it I have the following error ' Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints'

    but when I am using the dataadapter to fill the datatable, I don't have this msg anymore

    can any why what is the difference between the two method and why I have such error when I am using : MyTable.load(MyReader)

    thank you in advance for helpin.
    Sunday, December 6, 2009 3:16 PM

All replies

  • Some Code please?


    John
    Sunday, December 6, 2009 3:24 PM
  • Dim My_Table As New DataTable
    Dim My_Con As SqlConnection = New SqlConnection(Glbl_Conn_Config.My_Connection)
    Dim My_Command As SqlCommand = New SqlCommand("StPr_Login", My_Con)
    Dim My_Reader As SqlDataReader
    My_Command.CommandType = CommandType.StoredProcedure
    My_Con.Open()
    My_Reader = My_Command.ExecuteReader
    My_Table.Load(My_Reader)
    My_Con.close
    the instruction  My_Table.Load(My_Reader) cause the error.

    otherwise
    Dim My_Con As SqlConnection = New SqlConnection(Glbl_Conn_Config.My_Connection)
    Dim My_Command As SqlCommand = New SqlCommand("StPr_Login", My_Con)
    Dim My_Dataset As New DataSet
    Dim My_Adapter As New SqlDataAdapter(My_Command)
    My_Adapter.Fill(My_Dataset)
    Cause no error at all.

    Sunday, December 6, 2009 6:12 PM
  • Hello Wael,

    Could you please provide us some demo db file to repro this issue?   I have tested some simple table and stored procedure at my side but I cannot repro it.  If it is convenient for you, you can send me the db file via mail.  My mail address is v-micsun @ microsoft.com.

     

    Have a nice day!


    Best Regards,
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Codernator Thursday, December 31, 2009 11:41 PM
    Wednesday, December 9, 2009 10:06 AM
    Moderator
  • Hi,

    I have the same problem but it only happens when I use MySQL database, (I use a select with left joins and some columns returns nulls this is why the exception ocurrs), but this is weird because it only happens with MySQL. When I use MSSQL there is no problem.

    Best regards,
    I. Vite
    Thursday, January 21, 2010 11:36 PM
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML inside this file remove the duplicate template id's then its works fine.
    Tuesday, November 30, 2010 4:43 AM
  • Good Evening Lingzhi Sun

    Sorry for this late response but My mail was Stolen and I didn't realize your Response



    you find joined here the Script of the Database
    USE [Attendance management System Test]
    GO
    /****** Object: Table [dbo].[Tbl_Groups_Of_Users]  Script Date: 11/30/2010 18:46:57 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Tbl_Groups_Of_Users](
      [GroupId] [int] NOT NULL,
      [GroupName] [nvarchar](50) NOT NULL,
      [CreatedBy] [nvarchar](50) NULL,
      [CreatedIn] [datetime] NULL,
      [ModifiedBy] [nvarchar](50) NULL,
      [ModifiedIn] [datetime] NULL,
      [HostName] [nvarchar](50) NULL,
      [Activated] [bit] NULL,
      [RowVersions] [timestamp] NULL,
     CONSTRAINT [PK_Tbl_Groups_Of_Users] PRIMARY KEY CLUSTERED
    (
      [GroupId] DESC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    CREATE UNIQUE NONCLUSTERED INDEX [IX_Tbl_Groups_Of_Users] ON [dbo].[Tbl_Groups_Of_Users]
    (
      [GroupName] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    GO
    INSERT [dbo].[Tbl_Groups_Of_Users] ([GroupId], [GroupName], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (2, N'Check in', N'Madanir', CAST(0x00009CFB01364361 AS DateTime), N'Madanir', CAST(0x00009CFB01364361 AS DateTime), N'ACCOUNTING', 1)
    INSERT [dbo].[Tbl_Groups_Of_Users] ([GroupId], [GroupName], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (1, N'Administrator', N'Wael Hawari', CAST(0x00009CF600BAF279 AS DateTime), N'Wael Hawari', CAST(0x00009CF600BAF279 AS DateTime), N'HANIN', 1)
    INSERT [dbo].[Tbl_Groups_Of_Users] ([GroupId], [GroupName], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (0, N'Ultimate Control', N'Hawari Wael', CAST(0x00009CB5016EF350 AS DateTime), N'Wael', CAST(0x00009CB5016EF350 AS DateTime), N'HANIN', 1)
    /****** Object: Table [dbo].[Tbl_Users]  Script Date: 11/30/2010 18:46:57 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Tbl_Users](
      [UserId] [int] NOT NULL,
      [UserName] [nvarchar](50) NOT NULL,
      [GroupName] [nvarchar](50) NULL,
      [Password] [nvarchar](max) NULL,
      [UserLanguage] [bit] NULL,
      [CreatedBy] [nvarchar](50) NULL,
      [CreatedIn] [datetime] NULL,
      [ModifiedBy] [nvarchar](50) NULL,
      [ModifiedIn] [datetime] NULL,
      [HostName] [nvarchar](50) NULL,
      [Activated] [bit] NULL,
      [RowVersions] [timestamp] NULL,
     CONSTRAINT [PK_Tbl_Users] PRIMARY KEY CLUSTERED
    (
      [UserId] DESC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    CREATE UNIQUE NONCLUSTERED INDEX [IX_Tbl_Users] ON [dbo].[Tbl_Users]
    (
      [UserName] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    GO
    INSERT [dbo].[Tbl_Users] ([UserId], [UserName], [GroupName], [Password], [UserLanguage], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (3, N'Wael', N'Administrator', N'01CF16714F2D9BF48CF9BC7DCF9287214F7D339DF398DFF84E327414B7CF4E27', 0, N'Wael Hawari', CAST(0x00009D8500C3F574 AS DateTime), N'Wael Hawari', CAST(0x00009D8500C3F574 AS DateTime), N'HANIN', 1)
    INSERT [dbo].[Tbl_Users] ([UserId], [UserName], [GroupName], [Password], [UserLanguage], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (2, N'Ozone', N'Check in', N'BB2BD7CA4A327F84E6CD3979F8FA3828A50A08893C1B68F9D6715352C8D07B93', 0, N'Madanir', CAST(0x00009CFB01365C6D AS DateTime), N'Madanir', CAST(0x00009CFB01365C6D AS DateTime), N'ACCOUNTING', 1)
    INSERT [dbo].[Tbl_Users] ([UserId], [UserName], [GroupName], [Password], [UserLanguage], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (1, N'Madanir', N'Administrator', N'51EFE5ED2FCC0EB44190695F79B12BD2CDCFF01E7D0132446174F7A6B05BC017', 0, N'Wael Hawari', CAST(0x00009CF600BAF9D2 AS DateTime), N'Wael Hawari', CAST(0x00009CF600BAF9D2 AS DateTime), N'HANIN', 1)
    INSERT [dbo].[Tbl_Users] ([UserId], [UserName], [GroupName], [Password], [UserLanguage], [CreatedBy], [CreatedIn], [ModifiedBy], [ModifiedIn], [HostName], [Activated]) VALUES (0, N'Wael Hawari', N'Ultimate Control', N'C88A0FD7F055AEEC5D19F59A33FDBCA9AE6919072A27430683D36E64C2F9F169', 0, N'Wael Hawari', CAST(0x00009B5E016660A8 AS DateTime), N'Wael Hawari', CAST(0x00009B5E016660A8 AS DateTime), N'Hanin', 1)
    /****** Object: Table [dbo].[Tbl_Groups_Authorizations]  Script Date: 11/30/2010 18:46:57 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Tbl_Groups_Authorizations](
      [GroupName] [nvarchar](50) NOT NULL,
      [PermissionLabel] [nvarchar](50) NOT NULL,
      [Authorized] [bit] NULL,
      [UserName] [nvarchar](50) NULL,
      [HostName] [nvarchar](50) NULL
    ) ON [PRIMARY]
    GO
    CREATE NONCLUSTERED INDEX [IX_Tbl_Groups_Authorizations] ON [dbo].[Tbl_Groups_Authorizations]
    (
      [GroupName] ASC,
      [PermissionLabel] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    GO
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Employees', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Employees', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Employees', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dtld_Empls_Info', 1, N'Madanir', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dtld_Empls_Rcpt', 1, N'Madanir', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dtld_Empls_Att', 1, N'Madanir', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Check in', N'Dlt_Employees', 0, N'Madanir', N'ACCOUNTING')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Check in', N'Dlt_PreSchedule', 0, N'Madanir', N'ACCOUNTING')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Check in', N'Isrt_Attendance', 1, N'Madanir', N'ACCOUNTING')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Check in', N'Updt_Attendance', 1, N'Madanir', N'ACCOUNTING')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Ultimate Control', N'Atch_Permis', 1, N'Wael Hawari', N'Hanin')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Ultimate Control', N'Isrt_Grp_of_Users', 1, N'Wael Hawari', N'Hanin')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Ultimate Control', N'Isrt_Users', 1, N'Wael Hawari', N'Hanin')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Employees', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Salry_Employees', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Chg_Pswd', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Rst_Pswd', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Grp_of_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Grp_of_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Grp_of_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Atch_Permis', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Grp_of_Users', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Positions', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Positions', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Positions', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Positions', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Departments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Departments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Departments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Departments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Payments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Payments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Payments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Payments', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Cancellation_Reasons', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Cancellation_Reasons', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Cancellation_Reasons', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Cancellation_Reasons', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Titles', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Titles', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Titles', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Titles', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Tm_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Tm_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Tm_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Tm_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Slr_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Slr_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Slr_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Slr_Dedc_Frm', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Holidays', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Holidays', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Holidays', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Holidays', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Holidays_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Holidays_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Holidays_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Holidays_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Company_Policy', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Company_Policy', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Company_Policy', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Company_Policy', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Schedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_PreSchedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_PreSchedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_PreSchedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_PreSchedule', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Isrt_Attendance', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Dlt_Attendance', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Cslt_Attendance', 1, N'Wael Hawari', N'HANIN')
    INSERT [dbo].[Tbl_Groups_Authorizations] ([GroupName], [PermissionLabel], [Authorized], [UserName], [HostName]) VALUES (N'Administrator', N'Updt_Attendance', 1, N'Wael Hawari', N'HANIN')
    /****** Object: StoredProcedure [dbo].[StPr_Login]  Script Date: 11/30/2010 18:46:55 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:    <Author,,Name>
    -- Create Date: <Create Date,,>
    -- Description:  <Description,,>
    -- =============================================
    CREATE PROCEDURE [dbo].[StPr_Login]
      @UserName as nvarchar(50),@Password as nvarchar(4000),@HostName as nvarchar(50)
    AS
    BEGIN
      begin Tran
        begin Try
          declare @User_Id as nvarchar(10)
          declare @RowNumber as nvarchar(10)
         
          if (select Count(*)   from Tbl_Users with (Tablockx)
             where  Tbl_Users.Activated = 1
             and UserName = @UserName
             and Password = @Password) >0
          begin
          set @User_Id = (select UserId from Tbl_Users
            where  Tbl_Users.Activated = 1
            and UserName = @UserName
            and Password = @Password );
    
            declare @Date as Datetime = getDate()
            declare @Date_s as varchar(30) = convert( varchar(30),@Date,113)
             
             
            insert into Tbl_Login_Logout
              values(@UserName
              ,@Date_s,Null,@HostName)
             
            set @RowNumber = (Select max(RowNumber) from Tbl_Login_Logout with (Tablockx)
                       where UserName =@UserName)
            Select  UserId,
                UserLanguage as UserLanguage,
                Tbl_Users.UserName,
                Tbl_Users.GroupName ,
                getDate() as LoginTime,
                PermissionLabel as label ,
                Authorized as Authorized,
                @RowNumber as RowNumber,
                 RowVersions
                
            from  Tbl_Users,Tbl_Groups_Authorizations with (Tablockx)
            where  Tbl_Users.Activated = 1
            and Tbl_Users.UserName = @UserName
            and Password = @Password
            and Tbl_Users.GroupName = Tbl_Groups_Authorizations.GroupName
          End
        Commit
        End try
        begin Catch
        Rollback
        End Catch
      End
    GO
    /****** Object: ForeignKey [FK_Tbl_Groups_Authorizations_Tbl_Groups_Of_Users]  Script Date: 11/30/2010 18:46:57 ******/
    ALTER TABLE [dbo].[Tbl_Groups_Authorizations] WITH CHECK ADD CONSTRAINT [FK_Tbl_Groups_Authorizations_Tbl_Groups_Of_Users] FOREIGN KEY([GroupName])
    REFERENCES [dbo].[Tbl_Groups_Of_Users] ([GroupName])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[Tbl_Groups_Authorizations] CHECK CONSTRAINT [FK_Tbl_Groups_Authorizations_Tbl_Groups_Of_Users]
    GO
    /****** Object: ForeignKey [FK_Tbl_Users_Tbl_Groups_Of_Users]  Script Date: 11/30/2010 18:46:57 ******/
    ALTER TABLE [dbo].[Tbl_Users] WITH CHECK ADD CONSTRAINT [FK_Tbl_Users_Tbl_Groups_Of_Users] FOREIGN KEY([GroupName])
    REFERENCES [dbo].[Tbl_Groups_Of_Users] ([GroupName])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[Tbl_Users] CHECK CONSTRAINT [FK_Tbl_Users_Tbl_Groups_Of_Users]
    GO
    


    the Pb is in the Stored Procedure [StPr_Login]
    in Fact if I remove the Rowversion Field from this Query:
    Select    UserId,
                            UserLanguage as UserLanguage,
                            Tbl_Users.UserName,
                            Tbl_Users.GroupName ,
                            getDate() as LoginTime,
                            PermissionLabel as label ,
                            Authorized as Authorized,
                            @RowNumber as RowNumber,
                             RowVersions
                           
    everything worked fine!!! ( Rowversions is a timestamp field)

     

    thank you

     

    Tuesday, November 30, 2010 5:05 PM
  • Cool! 

    Hope you have a nice day!

    Thanks
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, December 1, 2010 1:29 AM
    Moderator
  • there is a miss understood

     

    why when i remove the rowversion the code Work?

    In fact I don't understand

    hope to have some answers

    Wednesday, December 1, 2010 5:43 PM
  • You should call:

     

    MyTable.BeginLoadData()

    '// Load your data here

     

    MyTable.EndLoadData()

     

    BeginLoadData disables constraints so you can add the data without having to ensure the constraint is met. EndLoadData() enables the constraints after your data has been loaded.

     

    Hopefully that helps.

    Tuesday, January 18, 2011 3:52 AM