本文介绍了在表中插入唯一数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cmd.CommandText = "insert into " + table + " values ('" + textBox1.Text + "', '" + textBox2.Text + "') where not exists(select * from " + table + " where character='" + textBox1.Text + "' and entity='" + textBox2.Text + "');";
i想在我的表中插入唯一数据而我是越来越此查询中的错误(其中的语法不正确)...
i want to insert unique data in my table and i'm getting error in this query (Incorrect syntax near where)...
推荐答案
cmd.CommandText = "if not exists (select * from " + table + " where character='" + textBox1.Text + "' and entity='" + textBox2.Text + "') insert into " + table + " values ('" + textBox1.Text + "', '" + textBox2.Text + "') where not exists";
谢谢,
Bhagyesh
Thanks,
Bhagyesh
这篇关于在表中插入唯一数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!