Dear all, I am facing this 'bug' that really drive me nut. I created a trigger for Update script and tested in Enterprise manager to ensure it function correctly. However, when I used both VB or Server explorer to update the table, it gives me error, Couldn't VB just act as a intermidary to make the call and SQL server is supposed to do all the jobs??
To explain it in a simple way, I have 3 TABLES, TABLE1 with column C1(key), C2(char) & C3 (bit). TABLE2 with C1(key) & C2(key) and TABLE3 with C1(key) and C2(key). I wrote a update trigger to fire if C3 changes from 0 to 1. It inserted records into TABLE3 from TABLE2 where TABLE1.C1 = TABLE2.C1. Below are tables with sample data.
TABLE1 C1 C2 C3
A 123 0
B 234 0
C 456 0
TABLE2 C1 C2
A XXX
B XXX
B YYY
B ZZZ
C JJJ
TABLE3 C1 C2
If I change C3 to 1 in the 1st record in TABLE1, it work fine and 1st record in TABLE2 was inserted to TABLE3 in both Enterprise Manager & VS. However, if I change C3 to 1 in the 2nd record, Enterprise Manager will correctly inserted 3 reocrds into TABLE3 but in VS, it flags error 'Key column information is insufficient or incorrect. Too many rows were affected by update'
Could anyone please advise how to stop VS from 'try to be clever' ??
my trigger script as below:
CREATE TRIGGER Table1_Trigger1
ON dbo.Table1
FOR UPDATE
AS
IF UPDATE (c1)
declare @C3 as bit
declare @Key as char(10)
set @c3 = (select c3 from inserted)
set @key = (select c1 from INSERTED)
if @c3 = 1
INSERT INTO Table3
(C1, C2)
SELECT C1, c2
FROM Table2
WHERE C1= @Key)
Thank you 2 2269
Hi AH,
Did you ask this question also in the newsgroup.
You are doing this with VS.net maybe positioning on the VB interface, but I see only SQL code in your message and no VB.
Adonet
<news://msnews.microsof t.com/microsoft.publi c.dotnet.framew ork.adonet>
Web interface:
<http://communities2.mi crosoft.com/communities/newsgroups/en-us/?dg=microsoft.p ublic.dotnet.fr amework.adonet>
I hope this helps a little bit?
Cor
Hi Cor,
The behavior you are seeing is more of difference between OLE DB andODBC. Enterprise Manager uses ODBC and VS uses OLEDB by default. If you connect to SQL Server via the OLEDB
Provider for ODBC you will see the same behavior as in Enterprise Manager.
In the scenario where multiple rows get updated by the trigger ODBC returns 1 record as being affected and OLE DB returns 3 records being affected. The problem is the VS tools think you have
only updated one row but OLE DB reports 3 rows have been changed. To be safe we consider this situation an error. There are a couple work arounds. On is to do the update statements your self
in VS. Just open SQL Pane on the VS Query Designer, right click, and select change type update. The other possibility is to add SET NOCOUNT ON at the beginning of your trigger.
Hope this helps,
Cameron Slade
Microsoft VSData Team
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
-------------------- From: "AH" <ha*****@hotmai l.com> Subject: SQL operation in Server Explorer differ from Enterprise Manager Date: Wed, 25 Feb 2004 12:17:31 +0800 Lines: 174 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_ 0008_01C3FB99.5 78BBE90" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <#j************ **@TK2MSFTNGP09 .phx.gbl> Newsgroups: microsoft.publi c.dotnet.langua ges.vb NNTP-Posting-Host: cm95.omega224.m axonline.com.sg 218.186.224.95 Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP09.phx.g bl Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:184516 X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
Dear all, I am facing this 'bug' that really drive me nut. I created a trigger for Update script and tested in Enterprise manager to ensure it function correctly. However, when I used both VB or Server
explorer to update the table, it gives me error, Couldn't VB just act as a intermidary to make the call and SQL server is supposed to do all the jobs??To explain it in a simple way, I have 3 TABLES, TABLE1 with column C1(key), C2(char) & C3 (bit). TABLE2 with C1(key) & C2(key) and TABLE3 with C1(key) and C2(key). I wrote a update trigger to
fire if C3 changes from 0 to 1. It inserted records into TABLE3 from TABLE2 where TABLE1.C1 = TABLE2.C1. Below are tables with sample data.TABLE1 C1 C2 C3 A 123 0 B 234 0 C 456 0 TABLE2 C1 C2 A XXX B XXX B YYY B ZZZ C JJJ TABLE3 C1 C2 If I change C3 to 1 in the 1st record in TABLE1, it work fine and 1st record in TABLE2 was inserted to TABLE3 in both Enterprise Manager & VS. However, if I change C3 to 1 in the 2nd record,
Enterprise Manager will correctly inserted 3 reocrds into TABLE3 but in VS, it flags error 'Key column information is insufficient or incorrect. Too many rows were affected by update'Could anyone please advise how to stop VS from 'try to be clever' ?? my trigger script as below: CREATE TRIGGER Table1_Trigger1 ON dbo.Table1 FOR UPDATE AS IF UPDATE (c1) declare @C3 as bit declare @Key as char(10) set @c3 = (select c3 from inserted) set @key = (select c1 from INSERTED) if @c3 = 1 INSERT INTO Table3 (C1, C2) SELECT C1, c2 FROM Table2 WHERE C1= @Key) Thank you This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bennett Haselton |
last post by:
I want to get an ASP.Net hosting account with my ISP, and I'm trying
to find out what level of access to the server is requried in order
for me to view the server in Server Explorer in Visual Studio .Net,
where you can see the available database, expand it to get a list of
tables, etc. What level of access is required? Of course you need to
have an account with the right user rights, but is there some specific
service that needs to be...
|
by: David Gray |
last post by:
Hello all,
Having problems connecting to an Oracle 9i database from within
SQL/Server 2000 using the Security/Linked Servers feature.
Server1 (SQL/Server)
-----------
Windows Server 2003, Standard edition
MS SQL/Server 2000
Oracle 9i Client kit (OLEDB & ODBC) & Enterprise management tools
|
by: Mark Huebner |
last post by:
I have Visual Studio 2003 Professional and MS SQL Server 2000 installed on
my laptop. For some reason, I can't create a new database with the Visual
Studio Server Explorer. The error message is "Cannot create databases on
this server". I made sure I started up my instance of SQL Server called
T30-THINKPAD so it is running. However, I can create (and delete) databases
with the Enterprise Manager. The views from Server Explorer and...
|
by: ik |
last post by:
ERROR after uninstalling SQL Server 2005 Express
I get this message,
SQLDMO has not been registered. Please re-run your setupand contact your
system administrator.
GREAT!!! ReInstalled SQL SERVER 2000 after playing around with SQL Server
2005...
|
by: mikew |
last post by:
I am working at a company that has been using MS SQL Server, and we are going to be switching over to postgresql next week. (Getting off of Windows will be a relief!)
I am very familiar with SQL Server's "Enterprise Manager", which is their GUI for accessing the db. I have been acquainting myself with pgAdmin. There are a number of things that I really like about pgAdmin, but there are a few things that SQL Server Enterprise manager can...
| |
by: Zorba.GR |
last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64
bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite
Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager Express
Edition v1.3.2 Win, IBM Tivoli System Automation v1.2.0 Linux, IBM
Tivoli Workload Scheduler Virtualized Data Centers v8.2 , other
IBM Tivoli CDs, WEBSPHERE EVERYPLACE MOBILE PORTAL v5.0 - ALTIUM , other IBM WebSphere Business CDs...
|
by: David |
last post by:
Hi, I have the Visual Studio .NET installed under Windows XP Pro, in
my laptop.
Right now I practice C#, and I don't know how to access and use the
SQL Server's Enterprise Manager tool.
Any help will be appreciated.
Thanks
|
by: David Tilman |
last post by:
I've gone throught the MSDN walkthrough "Creating a Web Application Using
Visual C# or Visual Basic". When I run the sample I get "Login failed for
user 'dbuser'" at the line with "SqlDataAdapter1.Fill(dSet)". The SQL server
is setup for mixed mode and I have a login in Enterprise Manager for the
dbuser account. I've setup a system DSN in ODBC on the client which tested
succesfully. In Visual Studio 2003 I've chosen "Preview Data..." for...
|
by: Ma³y Piotruœ |
last post by:
Hello,
(sorry for my English...)
Could you help me please with installing SQL Servera 2005 Express
Edition. I downloaded files:
SQLEXPR.EXE - Microsoft SQL Server 2005 Express Edition
SSEUtilSetup.EXE - SQL Server Express Utility
SqlServer2K5_BOL_Dec2005.msi - Books Online December 2005
and I tried to run them sequentially. After installing SQLEXPR.EXE
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |