字符串变量不取值 [英] string variable not taking values

查看:80
本文介绍了字符串变量不取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!!!
我有一个字符串varibale y.i给它分配了一些值,但是使用断点显示时什么也没给我显示.

我已经尝试过使用此

Hello!!!
I have a string varibale y.i am assigning it some values but it''s showing me nothing when seen using breakpoint.

I have tried using this

Dim y As String = ""
       y = String.Format("Select orderNo, Conver(nvarchar,orderDt,106) as orderDt,LvDays,Convert(nvarchar,leave_from,106) as leave_from,Convert(nvarchar,leave_to,106) as leave_to from leave_Taken where empId={0} and lvType ='EL' and DATEPART(YEAR,orderDt)<'" + nxtyear + "' order by DATEPART(YEAR,orderDt),DATEPART(MONTH,orderDt),DATEPART(DAY,orderDt) ", eid)



并使用此



and using this

y = "Select orderNo, Conver(nvarchar,orderDt,106) as orderDt,LvDays,Convert(nvarchar,leave_from,106) as leave_from,Convert(nvarchar,leave_to,106) as leave_to from leave_Taken where empId=" + eid + " and lvType ='EL' and DATEPART(YEAR,orderDt)<'" + nxtyear + "' order by DATEPART(YEAR,orderDt),DATEPART(MONTH,orderDt),DATEPART(DAY,orderDt) "



但是当我使用断点查看它时,它仅显示".请告诉我出什么问题了!!!!



but when i am seeing it using breakpoint it shows me "" only. Please tell me whats wrong !!!

推荐答案

您尚未执行带有String.Format的行-断点在执行该行之前停止,不会.
只需执行一次,它就会出现.

顺便说一句:如果要使用String.Format(这是一个很好的主意),为什么不正确使用它呢?
You haven''t executed the line with the String.Format on it yet - breakpoints stop before the line is executed, not after.
Single step once, and it will appear.

BTW: it you are going to use String.Format (and it is a very good idea) why not use it properly?
y = String.Format("Select orderNo, Conver(nvarchar,orderDt,106) as orderDt,LvDays,Convert(nvarchar,leave_from,106) as leave_from,Convert(nvarchar,leave_to,106) as leave_to from leave_Taken where empId={0} and lvType =''EL'' and DATEPART(YEAR,orderDt)<''" + nxtyear + "'' order by DATEPART(YEAR,orderDt),DATEPART(MONTH,orderDt),DATEPART(DAY,orderDt) ", eid)


成为


Becomes

y = String.Format("Select orderNo, Conver(nvarchar,orderDt,106) as orderDt,LvDays,Convert(nvarchar,leave_from,106) as leave_from,Convert(nvarchar,leave_to,106) as leave_to from leave_Taken where empId={0} and lvType =''EL'' and DATEPART(YEAR,orderDt)<''{1}'' order by DATEPART(YEAR,orderDt),DATEPART(MONTH,orderDt),DATEPART(DAY,orderDt) ", eid, nxtyear)


这篇关于字符串变量不取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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