English 中文(简体)
为什么Insert命令删除数据库中的旧行
原标题:Why the Insert command delete old rows in the database

我正试图使用insert命令在数据库中添加一行。

它成功地添加了行,但执行命令后数据库中的旧行被删除了! 

Dim connetionString As String
        Dim cnn As SqlConnection
        Dim cmd As SqlCommand
        Dim sql As String
        connetionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Datab1.mdf;Integrated Security=True;User Instance=True"


        sql = "INSERT INTO Table1 VALUES ( e ,  e )"    


        cnn = New SqlConnection(connetionString)
        Try
            cnn.Open()
            cmd = New SqlCommand(sql, cnn)
            cmd.ExecuteNonQuery()    

            cmd.Dispose()
            cnn.Close()
            MsgBox(" ExecuteNonQuery in SqlCommand executed !!")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

怎么了?

问题回答

查找在此表上创建的导致删除旧行的触发器。

如果你想快速列出数据库中有触发器的表,下面是如何做到的:

USE [YourDB]

SELECT

OBJECT_NAME(parent_id) AS TableName,

name AS TriggerName,

create_date AS CreationDate,

modify_date AS ModifyDate

FROM sys.triggers




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签