添加字符串时出现问题 [英] problem adding string

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

问题描述

大家好!

我已经接受了一个字符串变量,并向其中添加了一些查询.我面临的问题是该变量仅显示第一个字符串,而不显示第二个字符串,它应同时显示两个字符串.

Hi all!!

i have taken a string variable and i am adding some query to it. the problem that i am facing is that the variable shows only the first string and not the second string , it should show both the strings.

If monthNo = j Then
                   Dim string1 As String = ""
                   string1 = "Select sanctioned_amt from details_gpf_advance_employee where empid=" + eid + "  and "
                   string1 += "DatePart(Month, sanction_order_dt) = " + j + ""
                   sanctioned_amt = Dal.ExScalar(string1)
               End If



我使用断点来查找文本.第三行中的String1显示与前面相同的文本,但第五行中的string1也显示与第三行中string1相同的文本.它应该同时显示两个文本,但不显示.请帮助我找到问题.

问题出在



i used break points to find the the text. String1 int the third line shows the same text as in front of it but string1 in 5th line also shows the same text as that of string1 in third line. It should show both the text but it''s not showing.. Please help me find the problem.

problem is with the

"DatePart(Month, sanction_order_dt) = " + j + ""

部分.使用breakpoint

part. It''s showing "" when seen using breakpoint

推荐答案

这样的查询时,它显示为"

Your query like this

Dim string1 As String = ""
                  string1 = "Select sanctioned_amt from details_gpf_advance_employee where empid=" + eid + "  and "
                  string1 += "DatePart(Month, sanction_order_dt) = " + j + ""
                  sanctioned_amt = Dal.ExScalar(string1)



这样写



Write like this

Dim string1 As String 
                 string1 = "Select sanctioned_amt from details_gpf_advance_employee where empid=" + eid + "  and "
                 string1 += "DatePart(Month, sanction_order_dt) = " + j + ""
                 sanctioned_amt = Dal.ExScalar(string1)



现在它可以工作了

谢谢,
SP



Now it will work

Thanks,
SP


对字符串使用& =":
Use "&=" for strings:
string1 &= String.format("DatePart(Month, sanction_order_dt) = {0}",j)


这篇关于添加字符串时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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