C# SQL server当 IDENTITY_INSERT 设置为 ON 或某个复制用户向 NOT FOR REPLICATION 标识列中插入内容时
当IDENTITY_INSERT设置为ON或某个复制用户向NOTFORREPLICATION标识列中插入内容时,必须为表'InformationB'中的标识列指定显式值;...
当 IDENTITY_INSERT 设置为 ON 或某个复制用户向 NOT FOR REPLICATION 标识列中插入内容时,必须为表 'InformationB' 中的标识列指定显式值;
sql server的存储过程是这么写的:
ALTER PROCEDURE [dbo].[Synchronization]
AS
BEGIN
SET IDENTITY_INSERT TestB.dbo.InformationB ON
INSERT TestB.dbo.InformationB
(S_Name
,S_Sex
,S_Address
,S_Phone
,S_Number
)
SELECT S_Name
,S_Sex
,S_Address
,S_Phone
,S_Number
FROM TestA.dbo.Information
SET IDENTITY_INSERT TestB.dbo.InformationB OFF
END
程序测试代码:
private void btnSync_Click(object sender, EventArgs e)//A-->B
{
try
{
string sql = "Synchronization";
dataGridView2.DataSource = DBHelper.ExecuteDataTableB(sql);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
DBHelper.conn.Close();
DBHelper.connB.Close();
}
}
不知道问题出在哪 展开
sql server的存储过程是这么写的:
ALTER PROCEDURE [dbo].[Synchronization]
AS
BEGIN
SET IDENTITY_INSERT TestB.dbo.InformationB ON
INSERT TestB.dbo.InformationB
(S_Name
,S_Sex
,S_Address
,S_Phone
,S_Number
)
SELECT S_Name
,S_Sex
,S_Address
,S_Phone
,S_Number
FROM TestA.dbo.Information
SET IDENTITY_INSERT TestB.dbo.InformationB OFF
END
程序测试代码:
private void btnSync_Click(object sender, EventArgs e)//A-->B
{
try
{
string sql = "Synchronization";
dataGridView2.DataSource = DBHelper.ExecuteDataTableB(sql);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
DBHelper.conn.Close();
DBHelper.connB.Close();
}
}
不知道问题出在哪 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询