选择查询无效 [英] select query is not working

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

问题描述

select queue_id,patient_id,doctor_id,status from appointment where date='" +Txtdate.Text + "'













i想要在文本框中选择显示数据

但这个选择查询不起作用

使用它显示所有记录







i want display data as selected in textbox
but this select query is not working
using this its display all records

推荐答案

1。首先,使用 TryParse 检查Txtdate.Text中的日期字符串是否为有效日期[ ^ ]方法;

2.将转换后的日期值传递给sql查询

参见示例:

1. First, check that the date string from Txtdate.Text is a valid date using TryParse [^] method;
2. Pass the converted date value to the sql query
See example:
string dateString = "take the date string from Txtdate";
DateTime dt;
if (DateTime.TryParse(dateString, out dt))
{
     // pass dt to your sql query as parameter
}
else
{
    // Not a valid datetime";
}



你应该考虑使用一些日期选择器或日历控件自动返回日期类型,无需转换。


You should consider using some datepicker or calendar controls which automatically return date type, no need for conversion.


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

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