我有一个SQLSqlCeParameter
声明例如:
mySQLCommand1.CommandText = @"
INSERT INTO clientSubjectiveComplaints (clientSubComplaintCreated)
VALUES (@ClientSubComplaintCreated)
";
一旦INSERT
成功后我需要返回自动生成的 ID(INT 主键),以便我可以立即使用它INSERT
陈述。
这对于SqlCe
?请您提供一个例子。
像这样:
using (var connection = new SqlCeConnection(Settings.Default.Database1ConnectionString))
using (var command = connection.CreateCommand())
{
connection.Open();
command.CommandText = @"
INSERT Test (Name)
VALUES (@TestName)
";
command.Parameters.AddWithValue("TestName", "SomeName");
command.ExecuteNonQuery();
command.CommandText = "SELECT @@IDENTITY";
var id = command.ExecuteScalar();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)