了解Sql查询 [英] Understanding Sql Query

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

问题描述

在此查询中从临时表''DTLocal''数据显示文本框。在这里,我不明白为什么?使用标记。请帮帮我



In this query from temp table ''DTLocal'' data shown textbox. Here I cann''t understand why ? marks is used. please help me

txtTruckReceiptDate.Text = (DTLocal.Rows[0]["TruckReceiptDate"].ToString() == "" ? "" : DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"));

txtDocHODate.Text = (DTLocal.Rows[0]["DOCHODate"].ToString() == "" ? "" : DateTime.Parse(DTLocal.Rows[0]["DOCHODate"].ToString()).ToString("dd-MMM-yyyy"));

推荐答案

它基本上是一个三元运算符。问号与冒号相结合。

这样工作:



Its basically a ternary operator. The question mark combined with the colon sign.
Works like this:

string name = ABooleanExpression ? "Jack" : "Jill";





如果布尔值为true,则将分配变量名称作为杰克,如果没有,那么变量名将是吉尔。



在你的代码中参考这个理解,你就会得到它。

希望它有帮助。



-ANurag



If the boolean exp is true then the variable name will be assigned as Jack, if not then the variable name will be Jill.

Refer this understanding in your code and you will get it.
Hope it helps.

-ANurag


这是三元运算符 [ ^ ]。



It is a Ternary Operator[^].

引用:

条件? first_expression:second_expression;

condition ? first_expression : second_expression;

For first line of code...
condition - DTLocal.Rows[0]["TruckReceiptDate"].ToString() == ""
first_expression - ""
second_expression - DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"))



如果条件满足,将执行 first_expression ,否则将执行 second_expression



所以,对于第一行...


If condition is satisfied the first_expression will be executed, otherwise second_expression will be executed.

So, for first line...

txtTruckReceiptDate.Text = (DTLocal.Rows[0]["TruckReceiptDate"].ToString() == "" ? "" : DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy"));



这里检查 DTLocal.Rows [0] [TruckReceiptDate]的值.ToString( )



- > 如果值为,则会将分配给 txtTruckReceiptDate.Text

- > 否则它指定 DateTime.Parse(DTLocal.Rows [0] [TruckReceiptDate]。ToString())。ToString(dd-MMM-yyyy)) txtTruckReceiptDate.Text


Here it checks the value of DTLocal.Rows[0]["TruckReceiptDate"].ToString().
And
-> if the value is "", it assigns "" to txtTruckReceiptDate.Text,
-> otherwise it assigns DateTime.Parse(DTLocal.Rows[0]["TruckReceiptDate"].ToString()).ToString("dd-MMM-yyyy")) to txtTruckReceiptDate.Text


这篇关于了解Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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