Key Violation During Synchronization

Sep 10, 2006

Dear Friends

I restored same database in Publisher & subscriber.If I want to apply Transactional replication I have to apply initial snapshot.then I am getting key-violation problems during initialization .Some times Primary key table will be dropped before foreign key table.sometimes it won't able to drop some indexes.This I am getting if I am going for all tables of database.But here i need all tables.If I am going for selective table I don't have any problem.For avoiding this problem I tried all the options in table article option in publication wizard.But some na some key violation I am getting always.So please give me some better suggestion

Thanks in Advance

Filson

View 5 Replies


ADVERTISEMENT

Windows Synchronization Manager And Subscriber Web Synchronization

Dec 7, 2005

Hi,

View 5 Replies View Related

Web Synchronization - Completed Synchronization Starts Again

Sep 6, 2006

Hello everybody,

There is some strange behaviour i've recently noticed while watching synchronization progress in Replication Monitor on SQL 2005 Server Standard with merge replication configured. The merge process seems to repeat several times.

This is the initial synchronizaion (reinitalization at the subsciber). Client is using Microsoft.SQLServer.Replication objects from .net framework assemblies.

The synchronization starts normally (status is "Running"). The last message of selected session box shows (among other messages): "Beginning evaluating partial replication filters" then "Finished evaluating partial replication filters" and finally "Merge completed after processing xxx changes... etc." after a few seconds. Status changes to "Completed" and then... the merge process starts again!! "Beginning evaluating partial replication filters" etc. And this repeats about 15-20 times.

And so whole process takes about 15 minutes instead about 45 seconds to complete initial synchronization. The number of changes is "Merge completed after processing ..." never change since the first such message.

Is this some bug in web synchronization or some invalid configuration setting? Why does merge process repeat itself so many times??

Please help, thanks in advance.

Kuba

View 6 Replies View Related

Access Violation

Aug 22, 2001

How execption access violation error msg with severity 19 handled in sql7 ?

Thanks for info.

View 1 Replies View Related

DTS Integrity Violation

Jun 12, 2000

I having a problem importing a text file into an existing table using the DTS import wizard. The problem I am having is, I am getting an error message stating: Integrity violation: attempt to insert null data or data which violates constraints. The column the error is referenced to is an identity field and I am not trying to insert any data into the field. I have the allow insert identity box checked in the transformation section. Does anyone know about how to solve this problem.
Thanks
James

View 1 Replies View Related

Primary Key Violation When There Is Only One Row

Feb 23, 2000

I have a table with 5 columns .Length of the 2nd column is 4 characters.
I have to create a new database and copy the existing data.Alter the 2nd column to have 6 charactrers.
Append the values in 2nd column with 00.
I have only one row in the old database.
I am able to copy the rows.But after that when I try to update,it is giving primary key violation error.
What could be the reason?

View 1 Replies View Related

Access Violation

Oct 15, 2003

System Spec: OS = Windows 2000, SQL Server 7 SP4.

I'm getting the following error when I run a stored procedure which truncates a table then inserts data into it. There are no complex joins, order, group by or union clauses in the insert statement:

Error: 0, Severity: 19, State: 0
SqlDumpExceptionHandler: Process 17 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

I've read that this is fixed in SQL 7 SP2 but we're on SP4?? I have re-installed SQL SP4.

View 1 Replies View Related

Primary Key Violation ???????

Apr 8, 1999

I am running SQL 6.5 service pack 5a.

I keep getting a Attempt to insert duplicate key row in object... when I try to add a record. I know for a fact that the primary key is not being duplicated because I can look in the db and see that it is not there and if I continue to try to add it it will eventually succeed. Does anyone know what might be causing this?

Please email as well as post.

Thanks.
Carole

View 2 Replies View Related

Primary Key Violation

Jul 14, 2004

Hi,
I have got a very peculier kind of problem. My package is running on SQL 2000. There is a identity primary key in a table. Now when I submit the data from 2 different computer at the same time. Only one data is storing. The reason behind this is the primary key violation. as both the data are sending the request to the database at the same time.................n as the primary key is th identity column, it is storing one that value which is able to store the data at the forst hand.
Now plz help me out in this regard................. :confused:

View 11 Replies View Related

Anticipated PK Violation

Sep 6, 2004

I am maintaining a stored proc that does the following (pseudo code for simplicity)


INSERT INTO MyTable (CountColumn, ...) VALUES (1, ...)

-- 2627 = Primary key violation
IF (@@ERROR = 2627)
UPDATE MyTable SET CountColumn = CountColumn + 1
WHERE ...


Basically, try to create a new record with a PK and a count of 1. If a PK violation occurs, UPDATE the count of existing record.

Pretty simple logic. On some servers this works exactly as expected; the PK violation is caught and handled internally. On other servers, this error percolates out of the stored proc and causes the calling code to receive an error and fail. All servers are SQL Server 2000 SP3a Standard Edition. Any ideas why this happens?

Is there a better (and ideally as fast or faster) way to handle the INSERT/UPDATE issue? I can put the UPDATE first and INSERT if @@ROWCOUNT is 0, but that has the slight potential of a race condition where two processes try to INSERT the same PK at the same time.

View 5 Replies View Related

Violation Of Primary Key

Mar 30, 2008

Violation of PRIMARY KEY constraint 'PK_CUSTOM2'. Cannot insertduplicate key in object 'MHGROUP.Custom2'Is there ANY other reason this violation of the primary key wouldhappen OTHER than a trying to insert a duplicate record?This sql statement false due to the primary key violation:Insert Into MHGROUP.Custom2SelectClientNumber,MatterNumber,MatterDescription,'Y'From MG_EliteMatters EMLeft Outer Join MHGROUP.Custom2 C2On C2.CPARENT_ALIAS = EM.ClientNumberAnd C2.Custom_ALIAS = EM.MatterNumberWhere CPARENT_ALIAS Is Null And Custom_ALIAS Is Null---Custom2CREATE TABLE [MHGROUP].[CUSTOM2]([CPARENT_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNOT NULL,[CUSTOM_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL,[C_DESCRIPT] [varchar](254) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[ENABLED] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,CONSTRAINT [PK_CUSTOM2] PRIMARY KEY CLUSTERED([CPARENT_ALIAS] ASC,[CUSTOM_ALIAS] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]--MG_EliteMattersCREATE TABLE [dbo].[MG_EliteMatters]([Matters] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[ClientNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[ClientDescription] [varchar](254) COLLATESQL_Latin1_General_CP1_CI_AS NULL,[MatterNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[MatterDescription] [varchar](254) COLLATESQL_Latin1_General_CP1_CI_AS NULL,[LastDateModified] [datetime] NULL,[PracticeArea] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_ASNULL) ON [PRIMARY]

View 1 Replies View Related

Violation Of PRIMARY KEY

Sep 14, 2007

Jobs run at 1 am , sometimes fail with following error.

Violation of PRIMARY KEY constraint 'PK__xxxxx__300424B4'. Cannot insert duplicate key in object 'VW_xxxx . [SQLSTATE 23000] (Error 2627) The statement has been terminated. [SQLSTATE 01000] (Error 3621). The step failed.

when I am reruning 7 am job run successfully. Any advice will be great.

Thanks

View 11 Replies View Related

Primary Key Violation

Oct 7, 2006

Dear Friends,
I am a DBA and I am getting a lot of table locks due to unhandled errors in front-end developed by Power Builder, 5 years back. The backend is SQL Server 2000 Enterprise edition. Below I will explain the problem in detail.

The Big Problem.
{
Ø Users enter sales data into rm_salehdr (docid,..,..,..) table (LOCKED)
Ø The rm_salehdr table need a new docid
Ø The new docid will be generated by a function called as docnogen
Ø The docnogen function
o will select the last docid from ps_docno table
o add 1 to last value
o return docid to rm_salehdr
o update the last docid with the new value.
o ps_docno table will hold the lock till the insert transaction of rm_salehdr will saved. (LOCKED)
Ø If insert into rm_salehdr commit then the insert into ps_docno will be commit. (LOCK Released)
Ø If insert into rm_salehdr rolled back then insert into ps_docno will be rolled back.
Ø (LOCK Released)

}

The Bigger Problem
{
Ø At the same time if another spid select the last docno and completes it transaction before the first transaction then Primary key Violation will arise.
Ø While inserting into rm_salehdr if a user get a error due to primary key violation then user will popped up with a message box explaining the primary key violation error.
Ø If the user does not click the OK button then the transaction will not be ended and LOCK on the table will not released from rm_salehdr.
Ø The LOCK on ps_docno will also be continued.
}

The Biggest Problem
{

Ø My client doesn€™t want to modify the front-end, it is very expensive for them and deployment to remote site is also a problem for them.
Ø They want me to handle it from the backend.
}


Is it possible that to handle the error message and release the lock on rm_salehdr from backend.

Commit the data first in ps_docno so lock will be released
I want your valuable suggestions and advice.

Thanks in advance.
Regards,
Raj



View 4 Replies View Related

Violation Of PRIMARY KEY Constraint

Mar 23, 2005

Hi,
I am trying to insert into a table. I got the above error message then I deleted all the data in the table. But I am still getting this error.

Whats wrong?

View 2 Replies View Related

Violation Of Primary Key Error

Dec 13, 2005

hi,
I am trying to save the record which is displayed in the textbox by selecting a row in the datagrid. If i click the save button I am getting the following error.
Violation of PRIMARY KEY constraint 'PK_clientinfo'. Cannot insert duplicate key in object 'clientinfo'. The statement has been terminated.      
button save-----------
    conn.Open();    SqlCommand cmd = new SqlCommand("insert into clientinfo (client_name, address, telephone, fax, email, contperson1, dept, contpos1, contperson2, contpos2, rscompname, rscontperson, rsposition, actdate, acttime, instsno, actkey) values ('"+txtclientname.Text+"', '"+txtaddress.Text+"', '"+txttelephone.Text+"', '"+txtfax.Text+"', '"+txtemail.Text+"', '"+txtcntperson1.Text+"', '"+txtdept.Text+"', '"+txtcnt1pos.Text+"', '"+txtcntperson2.Text+"', '"+txtcnt2pos.Text+"', '"+txtcompname.Text+"', '"+txtrscntperson.Text+"', '"+txtrspos.Text+"', '"+txtactdate.Text+"', '"+txtacttime.Text+"','"+txtinstno.Text+"', '"+txtactkey.Text+"')", conn);    cmd.ExecuteNonQuery();    conn.Close();    BindData();    txtclear();       } 

View 1 Replies View Related

Concurrency Violation Error!

May 16, 2006

Hiim keep getting  the following errorConcurrency violation: the UpdateCommand affected 0 recordsI dunno whats wrong, im the only person using the database and program at the moment.Anyone know what im doing wrong?thanks 

View 1 Replies View Related

Access Violation In Sql Server

Sep 22, 2000

Hi,
I received this event in my eventlog

Error: 0, Severity: 19, State: 0
SqlDumpExceptionHandler: Process 6 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

What could be the cause of this??

Thanks in advance
Mikael

View 3 Replies View Related

ERROR MSG: Violation Of PRIMARY KEY

Apr 30, 1999

Hi,

On a regular basis, it seems that the primary key of my table gets corrupted and I get the error message below. I can still read the data but no longer update or insert.
There is no reason why there should be such error. I fix it by creating a temporary table and copying the data accross, then renaming the
table, but I would rather prevent it. Any thought on this??


<P>ODBC Error Code = 23000 (Integrity constraint violation)
<P>[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY
constraint 'PK___1__23': Attempt to insert duplicate key in object 'SiteList'

View 1 Replies View Related

How Do You Find A Primary Key Violation

Jan 11, 2005

I need to find out which record I am violating by trying to execute this stored procedure

ALTER PROCEDURE InsertCorovan2004
AS
INSERT INTO [GamingCommissiondb].[dbo].[Corovan_Table]
([TM #],
[FirstName],
[LastName],
[SS #],
[TerminationDate],
[Voluntary or Involuntary])

SELECT [TM #], FirstName, LastName, SocialSecurityNumber, TerminationDate, VoluntaryorInvoluntary
FROM dbo.TERMINATION
WHERE (TerminationDate BETWEEN CONVERT(DATETIME, '2004-01-31 00:00:00', 102) AND CONVERT(DATETIME, '2004-12-31 00:00:00', 102))

GO



when I execute it I get this error message
Server: Msg 2627, Level 14, State 1, Procedure InsertCorovan2004, Line 3
Violation of PRIMARY KEY constraint 'PK_Corovan_Table'. Cannot insert duplicate key in object 'Corovan_Table'.
The statement has been terminated.
Stored Procedure: GamingCommissiondb.dbo.InsertCorovan2004
Return Code = -4


I am trying to insert 2004 terms into the corovan table from TERMINATION table. How do you find out what records match from each table (compare the tables reocords for dups). How would I do this in the query analyzer since thats mainly what I use. I get a better understanding of how to create proceudure in the query analyzer so I;d rather stick to it.

In short I need to find the Culprit record that is preventing me from insert the 2004 records


Thank you

View 14 Replies View Related

Violation Of PRIMARY KEY Constraint

Sep 21, 2005

I know what this error means is that you can not insert duplicate primary keys in the table but the thing is I am checking the rows if they do not exist then insert otherwise don't do any thing these are the lines I am writing in my strored procedure can someone please let me know what I am doing wrong here.

If not exists
(Select * From GGP WHERE
FFECTIVE_DATE =@v_EFFECTIVE_DATE AND
ASSET_ID= @v_ASSET_ID AND
ASSET_TYPE = @v_ASSET_TYPE AND
Value = @v_Value AND
hour = @v_Hour)

INSERT INTO GGP
(ASSET_ID,ASSET_TYPE,Hour,Value,EFFECTIVE_DATE) values(@v_ASSET_ID,@v_ASSET_TYPE,@v_Hour,@v_Value, @v_EFFECTIVE_DATE)



The exact error is
Violation of PRIMARY KEY constraint 'PK_SP_GGP'. Cannot insert duplicate key in object

Thanks in advance.

View 7 Replies View Related

Violation Of PRIMARY KEY Constraint

Apr 10, 2006

When I try to insert data into a table (let's just call it MyTable for this post), I suddenly get the following error.

Violation of PRIMARY KEY constraint 'PK_MyTable'. Cannot insert duplicate key in object 'MyTable'.

My table does have a primary key field named 'id', which is an auto-incrementing BIGINT. The last record I successfully inserted received 14 in the id field, so I'm assuming the database is trying to assign 15 to the next. Unfortunately, there is already a record with an id of 15; the next available id is 21.

Is there a way to avoid these primary key collisions?

View 5 Replies View Related

Primary Key Violation Error

Apr 8, 2008

Can anyone help me in handling errors I'm trying to update Employee master table, but i get error messege of violating primary-key constraint

View 3 Replies View Related

Violation Of Primary Key Constraint

Mar 3, 2006

I'm trying to insert records into a table and getting the below error and not sure how to resolve it:

Server: Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_propertyItem'. Cannot insert duplicate key in object 'propertyItem'.
The statement has been terminated.

View 2 Replies View Related

Access Violation Problem - Need Help

Jun 18, 2007

I have a task i.e. to make the following query work.
But it shows me syntax error. I dont know what this query is doing and I have no concerns about it. so if any body could help me out that will be a big help :)

SHAPE {

SELECT * FROM Leads
WHERE 1=1
AND ( ([Lead Quality] NOT IN (1,5,6,7) )
AND ( idVendors = '{ADF4406A-ACB7-4610-A03F-702D86CC259F}' )
AND ( idLeads IN (select idleads from [vendors history] where status = 3) )
AND ( [received datetime] between '6/18/2007' AND '6/19/2007' )
AND ( [Lead Type] NOT IN (7,8) )
)
ORDER BY idVendors, [Customer ID]

}
AS [Leads Detail]

APPEND

( { SELECT * FROM [Leads Borrower Information] WHERE [CoBorrower Indicator] = 0 } As [Borrower Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Leads Borrower Information] WHERE [CoBorrower Indicator] = 1 } AS [CoBorrower Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Leads Property Information] WHERE [Mailing Address Indicator] = 0 } As [Property Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Leads Property Information] WHERE [Mailing Address Indicator] = 1 } AS [Mailing Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Leads Mortgage Information] WHERE [Mortgage Indicator] IN (0,1) } AS [First Mortgage Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Leads Mortgage Information] WHERE [Mortgage Indicator] = 2 } AS [Second Mortgage Information] RELATE 'idLeads' TO 'idLeads'),
( { SELECT * FROM [Vendors] } As [Vendor Information] RELATE 'idVendors' to 'idVendors'),
( { SELECT * FROM [Lead Quality Reason Values] } As [Return Reason] RELATE 'Lead Quality Reason' to 'Value'),
( { SELECT [Batch ID], idLeads, idVendorsOrders FROM [Vendors History] WHERE STATUS IN (1,2) } As [Vendor History] RELATE 'idLeads' to 'idLeads'),
( { SELECT TOP 1 idLeads, DateTime from [Clients History] WHERE Status IN (3) ORDER BY DateTime ASC } As [Clients History] RELATE 'idLeads' to 'idLeads')

View 3 Replies View Related

VIOLATION OF PRIMARY KEY CONSTRAINT

Feb 15, 2008

Violation of PRIMARY KEY constraint 'PK_tbl_others. Cannot insert duplicate key in object 'tbl_others.
The statement has been terminated.-- What does it mean i cant load the data to tbl_others

View 2 Replies View Related

Violation Of Primary Key Constraint

Apr 2, 2007

When replication merge, is taking place between two servers on one particular table I keep getting violation of primary key constraint, Does anyone out there have a fix for this?

View 1 Replies View Related

'check Constraint' Ignored - PK Violation

Jul 24, 2007

I thought the whole point of 'check constraint' being unticked meant you could whack your data straight in no probs.

How can I insert a bunch of historical information where I want to control the PK, in this case DealID?

I have got 'keep identity' checked.

I check the db, the Id does NOT exist currently.


Error: 0xC0202009 at Data Cleansing, Deal Insert [12194]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_DealID'. Cannot insert duplicate key in object 'dbo.Deal'.".

View 3 Replies View Related

Violation Of Primary Key Constraint

Jan 4, 2008

Hi,

I've a set of source tables on one server and a set of destination tables on another.
When I move data from one server to next, I get an error saying "Violation of Primary Key Constraint". This happens for only one table among the 6 tables that I have. I dont understand why it throws me this error. Though theres an error for this table, the data from source table moves into this destination table.

Am I missing something?


Thanks,
Subha Fernando

View 7 Replies View Related

Violation Of Primary Key Constraint

Jan 4, 2008


Hi,

I've a set of source tables on one server and a set of destination tables on another. I'm moving this using a data flow task.
When I move data from one server to next, I get an error saying "Violation of Primary Key Constraint". This happens for only one table among the 6 tables that I have. I dont understand why it throws me this error. Though theres an error for this table, the data from source table moves into this destination table.

Am I missing something?


Thanks,
Subha Fernando

View 5 Replies View Related

InsertCommand.ExecuteNonQuery() And Violation Of PrimaryKey

Jan 15, 2007

Hey,
I have a page that inserts into a customers table in the DataBase a new customer account using this function:
Public Function InsertCustomers(ByRef sessionid, ByVal email, ByVal pass, Optional ByVal fname = "", Optional ByVal lname = "", Optional ByVal company = "", Optional ByVal pobox = "", Optional ByVal add1 = "", Optional ByVal add2 = "", Optional ByVal city = "", Optional ByVal state = "", Optional ByVal postalcode = "", Optional ByVal country = 0, Optional ByVal tel = "")
Dim result As New DataSet
Dim tempid As Integer
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("Conn"))
Dim Adcust As New SqlDataAdapter
Adcust.InsertCommand = New SqlCommand
Adcust.SelectCommand = New SqlCommand
Adcust.InsertCommand.Connection = conn
Adcust.SelectCommand.Connection = conn
sessionExists(email, sessionid, 1)
conn.Open()
If fname = "" Then
Adcust.InsertCommand.CommandText = "Insert Into neelwafu.customers(email,password,sessionid) Values('" & email & "','" & pass & "','" & sessionid & "')"
Else
Dim strsql As String
strsql = "Insert Into neelwafu.customers"
strsql = strsql & "(sessionid,email,password,fname,lname,company,pobox,address,address2,city,state,postalcode,countrycode,tel) values("
strsql = strsql & "'" & sessionid & "','" & email & "','" & pass & "','" & fname & "','" & lname & "','" & company & "','" & pobox & "','" & add1 & "','" & add2 & "','" & city & "','" & state & "','" & postalcode & "', " & country & ",'" & tel & "')"
Adcust.InsertCommand.CommandText = strsql
End If
Adcust.InsertCommand.ExecuteNonQuery()
Adcust.SelectCommand.CommandText = "Select Max(id) from neelwafu.Customers"
tempid = CInt(Adcust.SelectCommand.ExecuteScalar())
conn.Close()
Return tempid
End Function
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Now, I am getting an error:
Violation of PRIMARY KEY constraint 'PK_customers_1'. Cannot insert duplicate key in object 'customers'. The statement has been terminated.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The customers table has as a primary key the 'email'.....
so plz can I know why am I getting this error ????
Thank you in advance
Hiba

View 4 Replies View Related

Capture Primary Key Violation Error

Sep 14, 2007

Hello,,
I need to capture the primary key violation error:
        If e.CommandName = "Insert" Then            Dim EmployeeIDTextBox As TextBox = CType(dvContact.FindControl("EmployeeIDTextBox"), TextBox)            Dim LastName As TextBox = CType(dvContact.FindControl("LastName"), TextBox)            Dim FirstName As TextBox = CType(dvContact.FindControl("FirstName"), TextBox)     
            Using cmdAdd As New System.Data.SqlClient.SqlCommand
                'Establish connection to the database connection                Dim sqlcon As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("eConnString").ToString)
                'Open connection                sqlcon.Open()
                'Pass opened connection (see above) to the command object                cmdAdd.Connection = sqlcon
                'Using "With/End With" pass content to columns from text objects and datatime variables (see above)                With cmdAdd                    .Parameters.Add(New SqlClient.SqlParameter("@EmployeeID", EmployeeIDTextBox.Text))                    .Parameters.Add(New SqlClient.SqlParameter("@LastName", LastName.Text))                    .Parameters.Add(New SqlClient.SqlParameter("@FirstName", FirstName.Text))                              'Establish the type of commandy object                    .CommandType = CommandType.Text
                    'Pass the Update nonquery statement to the commandText object previously instantiated                    .CommandText = "INSERT INTO ATTEmployee(EmployeeID, LastName, FirstName & _                         "VALUES (@EmployeeID, @LastName, @FirstName)"                End With
                'Execute the nonquerry via the command object                cmdAdd.ExecuteNonQuery() '<==Need to capture primaryKey violation, give user message, cancel insert,return to detailView ReadOnly
               'I haven't figured out the correct code to capture the primary key violation
               EDITMsg.Text="You can not insert an duplicate record.  Try Again."
                'Close the sql connection                sqlcon.Close()            End Using        End If
 
Thank you for your help

View 6 Replies View Related

Contraint Violation When Reading From Database

Apr 4, 2008

I have created a typed-dataset AuthorsDataSet and created a table in with name Authors, manually by right-click > New > Table. I have kept the data-types, sizes and contstriants exactly same as the table in the database, though I have kept the Column names different. I am filling the AuthorsDataSet with the following code on Form_Loadif (!IsPostBack)
{      SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString);
      SqlCommand cmd = new SqlCommand("SELECT au_id, au_lname, au_fname, phone, address, city, state, zip, contract FROM authors", conn);      using (SqlDataAdapter da = new SqlDataAdapter(cmd))
      {
            conn.Open();
            da.Fill(ds.Authors);
            grdAuthors.DataSource = ds.Authors;
            grdAuthors.DataBind();
            conn.Close();
      }
      conn.Dispose();
      cmd.Dispose();
}
The connection string is as follows:<connectionStrings>
      <add name="pubsConnectionString" connectionString="Data Source = localhost; Initial Catalog = pubs; Integrated Security = SSPI"/>
</connectionStrings>
The following error occurs when I run the page
System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

View 3 Replies View Related

Results Coming Through In Violation Of Criterion

Mar 6, 2002

I'm baffled by the results of the following query:
__________________________________________________ ______
select events.[report number], [microfilm number], [crash date]
into lowspeed
from events inner join vehicles
on events.[report number] = vehicles.[report number]
where [dummy record] = 'N'
and [estimated mph] between 1 and 10
and ([1st harmful event] = 01
or [2nd harmful event] = 01)
and [type of vehicle] in
('01','02','03','04','05','06','07','08','10','11' ,'12')
and [crash injury severity] = 5

select events.[report number], [microfilm number], [crash date]
into notlowspeed
from events inner join vehicles
on events.[report number] = vehicles.[report number]
where [dummy record] = 'N'
and [estimated mph] > 10
and ([1st harmful event] = 01
or [2nd harmful event] = 01)
and [type of vehicle] in
('01','02','03','04','05','06','07','08','10','11' ,'12')
and [crash injury severity] = 5

select distinct [report number], [microfilm number], [crash date]
into truelowspeed
from lowspeed where [report number] not in (select [report number] from
notlowspeed)

select [report number]
into pedtable
from pedestrians

select [report number],[microfilm number], [crash date]
as [Lowspeed Fatal Crashes - 1994]
from truelowspeed
where [report number] not in (select [report number] from pedtable)

drop table pedtable
drop table truelowspeed
drop table lowspeed
drop table notlowspeed
_______________________________________________

Let me explain what I'm trying to do.

In the first temp table "lowspeed," I'm trying to lump all crashes where a vehicle was doing between 1 and 10 mph.
In "notlowspeed," I'm setting up a table of crashes in which at least one vehicle was going over 10 mph.
By the third gyration, I'm trying to generate "truelowspeed;" which I thought would contain only crashes in which all of the criterion in the first two queries were satisfied and all of the vehicles involved in the crashes were doing between 1 and 10 mph (NO vehicles exceeding the 1 to 10 mph parameter).
The "pedtable" maneuver is simply to pull out any of these crashes in which a pedestrian was involved.
What I'm getting is a lot of crashes in which I have dummy records, several crashes in which one of the vehicles was going over 10 mph, and types of vehicles involved in the crash that should have been excluded by the criterion I specified.

Thoroughly stumped. Would be most grateful for any kind insight/advice.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved