如何使用一个连接执行多个查询 [英] How to execute multiple queries with one connection

查看:113
本文介绍了如何使用一个连接执行多个查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在vb.net中使用一个连接执行多个查询。

我正在使用Windows vb.net访问DB。



在我的项目中,我需要删除15个表的记录。

每次我需要打开连接并关闭每个删除语句的连接。

我需要插入15到20个表的记录。

执行需要很多时间。



是否可以通过一个连接从多个表中删除记录?



需要此代码



Sucharitha

Hi,

How to execute multiple queries with one connection in vb.net.
I am using windows vb.net with Access DB.

In my project i need to delete the records of 15 tables.
Every time i need to open the connection and close the connection for every delete statement.
Same way i need to insert the records for 15 to 20 tables.
It took lot of time to execute.

is it possible to delete the records from multiple tables with one connections?

Need code for this

Sucharitha

推荐答案

嗨嗨



你必须是调用sp来实现这个任务吧

所以在一次sp中你也可以删除你所有的表..



Hey hi

you must be calling sp to achieve this task right
so in once sp also you can delete all your tables..

USE [LTXFlow]
GO
/****** Object:  StoredProcedure [dbo].[save_Aging]    Script Date: 7/17/2013 5:44:39 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[save_Aging]
@Id int,
@dtTime datetime,
@Status varchar(30),
@UpldMstrId int,
@UpdatedBy int
as
begin
	if @Id=1
	begin


			insert into Tbl1(dtTime,[Status],UpdatedBy,UpldMstrId)values(@dtTime,@Status,@UpdatedBy,@UpldMstrId)
			insert into Tbl2(.....)
insert into Tbl3()
.
.
.
.
	
		
	end
end





而不是15个表调用15次,你可以在一个sp中添加15个insert语句。



instead of calling it 15 times for 15 tables you can add 15 insert statement in one sp.


这篇关于如何使用一个连接执行多个查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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