再作一个判断,判断该主建是否在表中存在,如果存在就执行update否则就insert
解决方案 »
- panel的scrollTop属性问题
- 一个入门级小问题,关于C#变量赋值的问题.大家来帮忙.
- 怎么在SQL中得到图片
- 显示窗体和隐藏窗体怎么写
- 关于截图的问题
- 在一个字符串中查找是否存在另一个字符串
- 用VS.net IDE写东西,有一些什么快捷键!
- trim方法
- debug或者uedit之类的工具??
- 存取另一個窗體中的數據
- 急救:用Excel做报表,怎样取得报表中控件的值,比如一个textBox的文本值。
- Response.Write("<script>alert('error');</script>");可以;Response.Write("<script>alert('error\n error');</script>");不可以,Why
begin
//Update
end
else
begin
//insert
end
如 billydong(billydong) 所说:
if exists(select id from mytale)
begin
//Update
end
else
begin
//insert
end
string str="select count(*) from table where id ="+你的id.tostring ()
sqlconnection conn= 你的连接
sqlcommand cm = new sqlcommand (str,conn);
int result = 0;
result =(int) cm.executsalary();
if result > 0
更新
esle
插入
begin
//Update
end
else
begin
//insert
end
select @ll=COUNT(*) from mytale
if @ll>0 then
begin
//Update
end
else
begin
//insert
end
conn.open();
Dataset dataset = new DataSet();
SqlDataAdapter dscommand = new SqlDataAdapter();
dscommand.SelectCommand = new SqlCommand( "Select id from table", conn);
dscommand.Fill( dataset );bool exist = false;
foreach( DataRow dr in dataset.Tables[0].Rows)
{
if( convert.ToInt32( dr["id"] ) == id )
{
exist = true;
}
else { exist = false; }
}if( exist )
{
// update;
}
else
{ // insert }