本文介绍了将文本转换为double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在将文本转换为double时遇到问题。为什么代码不起作用:

如果不是(txtdocbedrag.Text ="")那么


选择案例ddlBedrag.SelectedIndex


案例0


案例1


whereSQL + =" cast(bedrag as numeric(10, 2))> " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例2


whereSQL + =" cast(bedrag as numeric(10,2))> ; =''" &

Double.Parse(txtdocbedrag.Text)& "''和"


案例3


whereSQL + =" cast(bedrag as numeric(10,2))< ; " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例4


whereSQL + =" cast(bedrag as numeric(10,2))< ; =''" &

Double.Parse(txtdocbedrag.Text)& "''和"


案例5


whereSQL + =" cast(bedrag as numeric(10,2))= '' " &

Double.Parse(txtdocbedrag.Text)& "''和"


案例6


whereSQL + =" cast(bedrag as numeric(10,2))> ; =''" &

Double.Parse(txtdocbedrag.Text)& "''cast(bedrag as numeric(10,2))< " &

Double.Parse(txtBedragTot.Text)& "''和"


结束选择


结束如果

解决方案



我发现的一件事就是使用单引号标点符号围绕数字

值(Double.Parse(...)的结果。

在你的SQL查询中(这就是你正在构建的) ,更正?),数值

应该没有围绕它们的标点字符。字符串值需要

单引号,关于日期(在SQL Server中。访问日期标点符号是

#。)。


-

彼得[MVP视觉开发者]

杰克所有行业,无人掌握。







Hi,

I have a problem converting text to a double. Why doesn''t the code work:
If Not (txtdocbedrag.Text = "") Then

Select Case ddlBedrag.SelectedIndex

Case 0

Case 1

whereSQL += "cast(bedrag as numeric(10,2)) > ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 2

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 3

whereSQL += "cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 4

whereSQL += "cast(bedrag as numeric(10,2)) <= ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 5

whereSQL += "cast(bedrag as numeric(10,2)) = ''" &
Double.Parse(txtdocbedrag.Text) & "'' and "

Case 6

whereSQL += "cast(bedrag as numeric(10,2)) >= ''" &
Double.Parse(txtdocbedrag.Text) & "'' cast(bedrag as numeric(10,2)) < ''" &
Double.Parse(txtBedragTot.Text) & "'' and "

End Select

End If

解决方案


One thing I spotted is the use of single quote punctuation around a numeric
value (the result of Double.Parse(...).
In your SQL query (that is what you''re building, correct?), numeric values
should have no punctuation characters surrounding them. String values need
single quotes, as to dates (in SQL Server. Access date punctuation is the
#.).

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.







这篇关于将文本转换为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:48