Hi, I'm having an SSIS package which gives the following error when executed :
Error: 0xC002F210 at Create Linked Server, Execute SQL Task: Executing the query "exec (?)" failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.Task failed: Create Linked Server
The package has a single Execute SQL task with the properties listed below :
General Properties Result Set : None
ConnectionType : OLEDB Connection : Connected to a Local Database (DB1) SQLSourceType : Direct Input SQL Statement : exec(?) IsQueryStorePro : False BypassPrepare : False
Parameter Mapping Properties
variableName Direction DataType ParameterName
User::AddLinkSql Input Varchar 0
'AddLinkSql' is a global variable of package scope of type string with the value Exec sp_AddLinkedServer 'Srv1','','SQLOLEDB.1',@DataSrc='localhost',@catalog ='DB1'
When I try to execute the Query task, it fails with the above error. Also, the above the sql statement cannot be parsed and gives error "The query failed to parse. Syntax or access violation"
I would like to add that the above package was migrated from DTS, where it runs without any error, eventhough it gives the same parse error message.
I would appreciate if anybody can help me out of this issue by suggeting where the problem is.
I have a table X: ID (PK, int, not null) cstID(FK, int, not null) Name( nvarchar(100),not null) Desc( ntext, null)
I am using the table view in Enterprise manager, if I manually type in a new row, then I edit that row, setting "Desc" = NULL, then I delete that row (from within the table view) I get the error:
Data has changed since the results pane was last retrieved. Do you want to save your changes now? (Optimistic Concurrency Control Error)
Things to note: There was a FTI on this table, I deleted it, didn't help. No other process or users are editing/viewing this table The error doesn't occur if edit any other column, just setting the "Desc" to NULL creates this error.
Some other tables in my DB exhibit this same behavior, but not all......I can't figure out what the heck is going on...can you?
Hi, I'm writing a stored procedure and when I click on the Check Syntax button its giving me the error in the subject. I'm not really sure whats wrong with this. Here is my Stored Procedure code. Any help wud be appreciated.
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(); }
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'
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
I've recently migrated a SQL 2000 db to SQL 2005. There is a table with a defined primary key. In 2000 when I try importing a duplicate record my application would continue and just skip the duplicates. In 2005 I get an error message "Cannot insert duplicate key row in object ... with unique index..." Is there a setting that I can enable/disable to ignore and continue processing when these errors are encountered? I've read a little on "fail package on step failure" but not quite clear on it. Any tips? Thanks alot
I've read a few different articticles wrt how the handle this error gracefully. I am thinking of wrapping my sql insert statement in a try catch and have the catch be something likeIF ( e.ToString() LIKE '% System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_PS_HR_Hrs'. Cannot insert duplicate key in object %'){lable1.text = "Sorry, you already have reported hours for that day, please select anothe rdate" } Is there a better way?TIA Dan
I have a publication that has been working great for over eight months. I have on occassion had to stop publishing and stop subscribing in normal operation without problems.
Yesterday, I ran into a problem that I am not sure how to solve.
I keep getting a distribution task failure "Violation of Primary Key constraint 'aaaashipm_pk'. Attempt to insert duplicate key in object shipm failed while bulk copying into shipm
Anyone run across this or have any suggestions -- do I have a transaction log problem, distribution data base/log problem. I have checked the identity column to make sure its not out of sync, run a check on the table to make sure its not corrupted. I have a couple of other things I am trying but was curious if anyone else had come across this?
Will let you know if I find a solution but it doesn't look good.
I tried to do the merge replication between SQL 2000 database and the SQL mobile server on PDA with SQL server management studio from SQL 2005 and I have already successfully synchronized my PDA with one small SQL server database file. However when I tried to synchronized my PDA with another larger SQL server database file, I got the error on PDA as following: €œThe row operation cannot be reapplied due to an integrity violation. Check the publication filter. [Table = AuditCriterion, operation = Insert, RowGuid = {1ee9321d-f00d-410c-8d5b-08d4220d2627}]€?. I have keep checking the size of sdf file during synchronization, I found after the size of the sdf file stop increasing for about 20 mintues, then I got the error above. Morever, AuditCriterion table have a foreign key with another table AuditElement and I have not used publication filter at this stage.
The following SP causes the error "Violation of UNIQUE KEY constraint 'AlumniID'. Cannot insert duplicate key in object [table name]. The statement has been terminated." AlumniID is the table's PK and is set to autoincrement. I'd appreciate any help or suggestions.
1 ALTER PROCEDURE dbo.sp_CreateUser 2 3 @UserID uniqueidentifier, 4 @UserName nvarchar(128), 5 @Email nvarchar(50), 6 @FirstName nvarchar(25), 7 @LastName nvarchar(50), 8 @Teacher nvarchar(25), 9 @GradYr int 10 11 AS 12 SET NOCOUNT ON; 13 --DECLARE @UserID uniqueidentifier 14 --SELECT @UserID = NULL 15 --SELECT @UserID = UserID FROM dbo.aspnet_Users WHERE LOWER(@UserName) = LoweredUserName-- AND @ApplicationId = ApplicationId 16 INSERT INTO [table] 17 (UserID,UserName,Email,FirstName,LastName,Teacher,GradYr) 18 VALUES (@UserID,@UserName,@Email,@FirstName,@LastName,@Teacher,@GradYr
Hi there. We're doing a save on a MS Great Plains with SQL Server screen and get the following error: "A save operation on table 'WS_Time_Sheet_TRX_WORK' failed because a database constraint was violated."
If I hit More Info it says: [Microsoft][ODBC SQL Server Driver][SQL Server]INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_WS10702_UPR00100'. The conflict occurred in database 'NSP', table 'U00100PR', column 'EMPLOYID'.
I know these messages probably make perfect sense to you guys, but I'm a newbie. Can you point me in the right direction? My thinking is that maybe I should force the foreign key constraint using the "WITH NOCHECK" option or maybe the wrong data type is mapped between the two tables sharing the Foreign Key and the key should be deleted and recreated.
Any help you can provide would be most appreciated! Assume that I'm a newbie and that I know very little. You won't hurt my feelings if you "dumb it down" so I can understand where to begin! lol I'm not even entirely sure I know where to look to edit the connection in the first place.
I have a table with 0 records. When I try to insert records using a SP, it gives the following error. Violation of UNIQUE KEY Constraint 'constraint name'. Cannot insert duplicate key in object 'Objectname'. How do I resolve this. Thanks.
My SSIS control flow includes a standard "textbook" WMI Event Watcher Task that monitors a folder for incoming files. Generally it works fine, but now I regularly see the error message:
"Watching for the Wql Query caused the following system exception: "Quota Violation." Check the query for errors or WMI connection for access rights/permissions"
I do not see any indication of trouble in the event logs. The SSIS log simply states that it failed.
Is there any magic about WMI Event Watcher?
When I restart, it runs fine for hours.
SQL05 is 9.0.3054 on W2003 with all microsoft updates applied. It is basically a bare machine with SQL Server, SSIS running and a service that kicks in occasionally.
Hi guys! I am using SQL 2005 and I wonder why I am encountering the error "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" everytime I am trying to create stored procedure with temp table and table variable. See my code below with temp table.
Any thoughts will be appreciated!
CREATE PROCEDURE DBO.SAMPLESP (@DETAILS AS VARCHAR(8000), @ID AS VARCHAR(15))
AS
BEGIN TRANSACTION
CREATE TABLE DBO.#TEMPTABLE { ASSET VARCHAR(50) }
DECLARE @INSTINSERT AS NVARCHAR(4000) SET @INSTINSERT= 'INSERT INTO #TEMPTABLE(ASSET)' SET @INSTINSERT= @INSTINSERT+ @DETAILS
EXEC sp_ExecuteSQL @INSTINSERT
INSERT INTO InstDetail (TrackNum, ASSETID) SELECT @ID, A.ASSE FROM #TEMPTABLE A
DROP TABLE #TEMPTABLE
IF @@ERROR != 0 BEGIN ROLLBACK TRANSACTION RAISERROR('There was an error in here', 11, 1) RETURN END ELSE COMMIT TRANSACTION
I have tried several times to install SQL server onto an NT4.0 server which is more than capable of having more than one application to cope with, however, when going through the install procedure the programm stops with the following message
DR.Watson Access Violation Setup.exe In address :
Any hints as to where the problems lies or point me inthe right direction would be appreciated.
Hi everybody,I need to understand how concurrency excatly work in asp.net. For example, I'm confused what happens if two users at the same time try to access the same record in a table or even the same variable. Do ASP.NET handle this , I mean by locking one user and letting the other to have access OR it's up to the programmer to write some code to lock shared resources such as database , objects and variables?If it's up to the programmer to do this task, I appreciate if you can show me an example that clarifies that.Thank you
Following on from a thread I started about "concurrency" (real-time-ishsystem), I thought I would play about to see if I could easily adapt my datamodel to take account of potential multi-user write conflicts. So, I wouldappreciate you checking my logic/reasoning to see if this kind of thingwill work. Below I have a stored procedure that will simply delete a givenrecord from a given table. I have appended a "_Written" counter to thecolumns of the table. Every time the record is written, the counter isincremented. Clients store the current _Written count in their objects andpass this in to any write procedure executed.The procedure explicitly checks the _Written count within the transaction tosee if it agress with the written count passed in by the client. If it doesnot, the client throws an error. Note I am explicitly checking the_Written count precisely so I can determine exactly why this operation mightfail, rather than checking @@ROWCOUNT after an update.Thanks.RobinCREATE PROCEDURE dbo.proc_DS_Remove_DataSet@_In_ID INTEGER,@_In_Written INTEGERASDECLARE @Error INTEGERDECLARE @WRITTEN INTEGERBEGIN TRANSACTIONSET @Error = @@ERRORIF @Error = 0BEGINSELECT @WRITTEN = _Written FROM MyTable WHERE ID = @_In_IDSET @Error = @@ERRORIF @WRITTEN <> @_In_WrittenBEGINRAISERROR ('10', 16, 1)SET @Error = @@ERRORENDENDIF @Error = 0BEGINDELETE FROM MyTable WHERE ID = @_In_IDSET @Error = @@ERRORENDIF @Error = 0COMMIT TRANSACTIONELSEROLLBACK TRANSACTIONRETURN @Error
Do single commands (or stored procedures) execute concurrently, or they are executed one by one. How do you perform a lock during the execution of a command (or stored procedure).
I have a user object that is stored in the session for each user but what if an administrator updates a certain user and I want to reflect the update to the user if they are logged in?One possible way of solving this is:Each time the user goes to a page, check the user table and compare the timestamp. That would mean if 30 users refresh the page..the db would hit 30 times lol. I don't think that would scale very well.Any ideas on how to solve this?
I have a table where I count how many emails of a given type are sent out each day. This incrementing is wrapped in a sproc that either inserts a new row, or updates the existing row. The column that counts the value is named Count of type INT. Below is the sproc, seems like a straightforward thing. However, I'm seeing email counts higher than they should be when there's a high number of concurrent executions of the sproc. I'm pretty sure it's not a problem in the calling code, so I'm wondering about the UPDATE statement, since it updates a column based on the value of the column. I would think this should work since it's wrapped in a SERIALIZABLE transaction, anybody have further insight? SQL Server 2005 by the way. Sean CREATE PROCEDURE [dbo].[IncrementEmailCounter]( @siteId SMALLINT, @messageType VARCHAR(20), @day SMALLDATETIME) ASBEGIN SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRANSACTION IF (SELECT COUNT(*) FROM EmailCount WHERE SiteId = @siteId AND MessageType = @messageType AND [Day] = @day) = 0 INSERT INTO EmailCount (SiteId, MessageType, [Day], [Count]) VALUES (@siteId, @messageType, @day, 1) ELSE UPDATE EmailCount SET [Count] = [Count] + 1 WHERE SiteId = @siteId AND MessageType = @messageType AND [Day] = @day COMMIT TRANSACTION SET TRANSACTION ISOLATION LEVEL READ COMMITTEDEND
I'm wondering whether the following code would work if users are RAPIDLY registering (assumption) WITH the same username.public bool UsernamExists(string username) { string sql = "SELECT true FROM [users] WEHRE username = @username;"; return Convert.ToBoolean(comm.ExecuteScalar()); }
//update or insert sql for user etc blah blah } If two users try to signup AT THE VERY SAME TIME (DOWN TO THE NANOSECOND), would this technique work? Do I have to wrap it in a transaction, stored procedure?? Thanks.
Hi,I'm trying to implement Optimistic Concurrency in asp 2 but so far it has caused me nothing but problems.First, when doing an UPDATE I tried to use the primary key & a timestamp field which I had in SQL Express.. VS 2005 generated the stored procedures fine however when it came to the actual updating I think there was a problem with the conversion of the timestamp field when it was being stored in a text box (in a FormView control). So.. as a result that failed. And also I checked sooo many places online and haven't been able to find any examples of code where a timestamp was used with success in asp2.Next, I got ride of the timestamp type (in SQL Express database) and used a datetime and then.. I just implemented Optimistic Concurrency by passing in ALL the values (ie all the original values) like is proposed http://www.asp.net/learn/dataaccess/tutorial21vb.aspx?tabid=63 . This... works however I really do not want to have to pass in ALL these values (ie original and new).Ideally I would like to be able to use the primary key & the datetime field to handle the Optimistic Concurrency checks where only the original values of both those fields are passed back into the stored procedure. Now.. I tried this as well, but I kept getting an error that suggests that (for some reason) the FormView or DataSource is passing ALL the values (original & new) into the dataset as opposed to only the original primary key & datetime fields & the new set of values.Can ANYONE offer any help? I really would like not to have to pass in all these values.Thanks in advance!
Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for my database server. How should I do to guarantee the integrity of the data in spite of the concurrent access? Meaning... how can I make sure that more than 1 user can update 1 table at the same time, while no error will occur? Do I need to add some codes at my aspx file? Or do I need to do something to my database? Or do I not have to worry about it? Thank you.
Can anyone help with concurrency issues. Small network and only one person at a time can log into the database. It was originally written in MS Access and converted to SQL 7.0 with a VB front end.
Is there any way to get the sample below working so that both "threads" are guaranteed to get unique and incrementing values?
I'm suspecting the answer is no. You can use transactions on completely database oriented operations that read/write to a database and complete. But there aren't complete synchronization controls for operations like below that try to return a value to an outside process.
IF OBJECT_ID('SimpleTable') IS NOT NULL DROP TABLE SimpleTable
CREATE TABLE SimpleTable ( A INTEGER ) INSERT INTO SimpleTable (A) VALUES (1)
-- Run in one window DECLARE @value INTEGER
BEGIN TRANSACTION SELECT TOP 1 @value = A FROM SimpleTable WAITFOR DELAY '00:00:05' UPDATE SimpleTable SET A = @value + 1 COMMIT TRANSACTION
SELECT @value SELECT A FROM SimpleTable
-- Run in a second window DECLARE @value INTEGER
BEGIN TRANSACTION SELECT TOP 1 @value = A FROM SimpleTable UPDATE SimpleTable SET A = @value + 1 COMMIT TRANSACTION