c# - 使用 mysql 和 c# 编程语言搜索存在的时间
问题描述
我想要的是搜索给定的小时是否已经存在于我正在使用 MySQL 数据库和 c# 编程语言 win.form 的数据库中。
string connection = "datasource=localhost;username=root;password=root";
MySqlConnection conDatabase = new MySqlConnection(connection);
DataSet ds = new DataSet();
MySqlCommand cmdDatabase = new MySqlCommand("SELECT * FROM
parking_reservation.bookedslots WHERE entryHour =
'"+this.EntryHour.Value+"'", conDatabase);
try
{
MySqlDataAdapter sda = new MySqlDataAdapter(cmdDatabase);
sda.Fill(ds);
int i = ds.Tables[0].Rows.Count;
if (i > 0)
{
MessageBox.Show("Already Booked");
ds.Clear();
}
else
{
MessageBox.Show("Booked Successfuly");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
解决方案
推荐阅读
- amazon-quicksight - 有没有办法在快速查看日期下拉列表
- angular - Angular Cookie 会话 ID
- azure - Azure 数据工厂:处理 until/for 活动中的内部故障
- c - 在子进程中禁止 printf
- angular - 如何在输入上创建固定只读前缀?
- elastic-stack - 是否使用 docker 运行 Beats?
- c++ - CLion、SDL2、CMake:没有可用的视频设备
- ios - 当我们在swift中使用MKMapView点击mapView时如何移动到第二个Viewcontroller?
- swift - 无法在集合视图上获取 indexPath 和选择
- java - 如何在 JSP 页面中显示列表结果?