输入文本框并填写其他字段 [英] Type in textbox and fill in other field

查看:168
本文介绍了输入文本框并填写其他字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个工作数据库。一个叫做EquipmentDB,一个叫做EmployeeDB



我创建了另一个表单。我想在文本框中键入员工的公司ID,然后单击一个按钮。员工的其余细节将在文本框或标签中显示如下:



姓名:

部门:



PS:我的数据库中有2个这个字段。



之后会有另一个文本框输入设备的条形码。同样的事情,点击按钮显示条形码详细信息。



ItemName:

类别:



是否可以在一种形式中使用2个数据库?

i have 2 working databases. one is called EquipmentDB one is called EmployeeDB

I created another form. I want to key in the Company ID of the employee in the textbox and click a Button. The rest of the details of the employee will display in textbox or label as followed:

Name:
Department:

P.S: i have 2 of this field in my database.

After that there will be another textbox to type in the barcode of the equipment. Same thing, click a Button display the barcode details.

ItemName:
Category:

Is it possible to use 2 database in one form?

推荐答案

您好,



尝试以下方法,



http:// stackoverflow .com / questions / 11855651 / multiple-connection-string [ ^ ]


如果您的数据库位于不同的服务器上,则可以使用两个连接字符串。但是,如果您在同一服务器上安装了数据库,则可以将数据库名称作为变量传递给存储过程,并在那里创建动态查询。例如:



If you have your databases on different servers you can use two connection strings. But if you have your databases on the same server you can pass database name as a variable to your stored procedure and there you can create a dynamic query. For example:

Create Procedure CompanyDetails
(@companyID int,@databaseName varchar(50))
AS
BEGIN
declare @sql varchar(500)
set @sql = 'select * from ' + '[' + @databaseName +'].dbo.CompanyDetailsTable where companyId = ' + Convert(varchar(10),@companyID)
exec @sql
END


这篇关于输入文本框并填写其他字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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