c# - 我没有使用 request.QueryString 从 sql 数据中获取值
问题描述
我正在使用 asp.net webform & C# 以及 SQL 创建一个简单的页面。请看一下代码,这将更容易理解
public string settype;
int qid;
settype = System.Convert.ToString(Request.QueryString["settype"]);
qid = System.Convert.ToInt16(Request.QueryString["qid"]);
有一个带有 settype 和 qid 的表,使用上面的代码我得到了 settype 值,但我无法得到 qid 的值。它保持为空。我错过了什么吗?
sql 中 qid 的数据类型是 numeric(18,0)
解决方案
Before fetching the QueryString value we have to check the null condition it is best practices. Below the code
decimal qid=0.0M;
if (!string.IsNullOrEmpty(Request.QueryString["qid"]))
qid= Convert.ToDecimal(Request.QueryString["qid"])
推荐阅读
- java - 如何使用 ImageJ 自动测量透明粒径?
- angular - 使用 PDFMake-Wrapper 将 PDF 转换为 PDF 图像 - Angular
- android - 脚本只能关闭它们打开的窗口。- 颤振网页视图
- sql - postgreSQL 排他排序
- kafka-partition - 如何在kafka中创建分区
- jquery - 带有 jQuery('body') 的 Click 事件有效,但 jQuery(document) 无效。为什么?
- ios - 设置 .delegate = self 是属性注入吗?
- java - 将请求体中封装的 JSON 数据反序列化为两个不同的模型对象
- php - php 文件不断出现双换行符
- c# - 如何使用 wpf 应用程序中的文件路径在发布请求上上传 .pdf 文件?