怎么写查询?在2个表格中插入数据 [英] how to write query ? insert data in 2 table

查看:73
本文介绍了怎么写查询?在2个表格中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

假设我有两个桌子
1位员工
2作为订单

在这种情况下,我已经通过设计部分在数据库中输入了值,
所以我该如何为该错误编写查询,

我通过一个查询在两个表中都插入了值.....

example :

suppose i have two table
1 as Employee
2 as Order

in this case i have enter the value in database through design part ,
so how can i write query for this error,

i have insert value in both table through one query.....

推荐答案

insert blah into Employee; insert blah into Order; 



注意将两个语句分开的分号.这是技术上"的两个查询,但是您可以通过一次调用SqlCommand.ExecuteNonQuery()来运行它们.



Notice the semi-colon separating the two statementes. It''s "technically" two queries, but you can run them both with a single call to SqlCommand.ExecuteNonQuery().


您可以使用触发器
请看这个
这可能对您有帮助
http://khanrahim.wordpress.com/2009/12/04/how-to-write-trigger-in-sql-server-2005/
谢谢
Faisal
You can use trigger
please look at this
this might help you
http://khanrahim.wordpress.com/2009/12/04/how-to-write-trigger-in-sql-server-2005/
thanks
Faisal


使用SqlCommand从代码中执行存储过程.
将正确的参数传递给过程时,可以在此处执行insert语句.

J.
Execute a stored procedure from your code with the SqlCommand.
When you pass the correct parameters to your procedure, you can do the insert statements in here.

J.


这篇关于怎么写查询?在2个表格中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆