获取数据库int值并使用int变量。 [英] Fetching data base int value and using as int variable.

查看:125
本文介绍了获取数据库int值并使用int变量。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我再次需要你的帮助,我想从sql server 2008数据库中获取数据(表(int value)的id)并将其用作c #windows窗体中的变量。我想在另一个sql查询中使用该变量来匹配该变量来获取整行。

Hello,

Once again i need your help , I want fetch data (id of table (int value)) from sql server 2008 database and use it as variable in c# windows form. i want to use that variable in another sql query to fetch entire row by matching that variable.

推荐答案

Declare @id int
Select @id = IdCol1 from table1 where col2 = 'abc'





现在变量'@Id'你有了价值。现在您可以直接将其用于其他查询,例如





Now in variable '@Id' you have the valu. Now you can use it directly to other query like

select * from table2 where col1 = @Id





或者在c#中将其提取到int变量并将其作为参数传递给其他sp / query。



Or fetch it to int variable in c# and pass as parameter to other sp/query.


这篇关于获取数据库int值并使用int变量。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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