如果database列为null,则用string替换

编程入门 行业动态 更新时间:2024-10-24 00:24:16
本文介绍了如果database列为null,则用string替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

i只想问一下如何使用sql server在C#中编写以下场景: 1.我正在编写一个页面,反映表单是否已经提交。我有[name]列和[date submitted]列。 2.我想替换[date submitted]列中的数据。如果[提交日期]有条目,我希望将其反映为已提交,如果[提交日期]为空,则无法提交。 3. [名称]和[提交日期]来自不同的数据库:mydb.name和project.dateSubmitted 4.它将反映到一个gridview 5.在gridview内部,会有一列按钮。如果[提交日期]为空,则该按钮将被禁用。如果[提交日期]有条目,则启用。 感谢

i just want to ask how to code in C# using sql server the following scenario: 1. I am coding a page that reflects if a form is already submitted or not. i have [name] column and [date submitted] column. 2. I want to replace the data inside the [date submitted] column. I want to reflect it as ALREADY SUBMITTED if [date submitted] has entry and NOT YET SUBMITTED if [date submitted] is null. 3. [name] and [date submitted] comes from different databases: mydb.name and project.dateSubmitted 4. it will reflect into just one gridview 5. inside gridview, there will be a column for buttons. if [date submitted] is null, the button will be disabled. enabled if [date submitted] has entry. thanks

推荐答案

尝试 Try //dr is datareader if ( dr[0][0] is DBNull ) { //Handle null here }

处理此问题的最佳方法是从数据库中获取所需的结果。查询将如下所示: The best way to handle this is get the required result from the database. The query would be like the one below: SELECT NAME, CASE WHEN dateSubmitted IS NULL THEN 'NOT YET SUBMITTED' ELSE 'ALREADY SUBMITTED' END 'STATUS' FROM MYTABLE

更多推荐

如果database列为null,则用string替换

本文发布于:2023-10-24 13:46:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:则用   database   null   string

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!