Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在sql数据库和组合框之间检查数据?_C#_Sql Server_Wpf_Time_Dataset - Fatal编程技术网

C# 如何在sql数据库和组合框之间检查数据?

C# 如何在sql数据库和组合框之间检查数据?,c#,sql-server,wpf,time,dataset,C#,Sql Server,Wpf,Time,Dataset,我想添加一个新行: SqlDataAdapter da = new SqlDataAdapter("select time from foglalas", c1); SqlCommandBuilder scb = new SqlCommandBuilder(da); da.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataSet ds = new DataSet(); da.Fill(ds, "fog"); DataRow uj

我想添加一个新行:

SqlDataAdapter da = new SqlDataAdapter("select time from foglalas", c1);
SqlCommandBuilder scb = new SqlCommandBuilder(da);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
DataSet ds = new DataSet();
da.Fill(ds, "fog");
DataRow uj = ds.Tables["fog"].NewRow();

组合框值12:00根据您对问题的评论,我认为选择
可能会对您有所帮助。我在这里输入了一些代码原型:

var valueFromCombobox = "12:00";
var fog = ds.Tables["fog"];
DataRow[] foundRows = fog.Select("time = '" + valueFromCombobox + "'");
if (foundRows.Length > 0)
    Console.WriteLine("Already there!");
else
    Console.WriteLine("Not there yet - add it.");

不太清楚你在问什么。是否要查找您的
ds
中是否有“12:00”?如果是的话,已经有人问过了。如果不是这样的话,请考虑你的问题。换句话说,我有一个包含时间格式的组合框(1,00,2……等等),并且在数据库中,我节省时间格式(1 00,2点……23点),并且我不想因为冗余而增加相同的时间,我如何检查2个数据(在数据库和组合框之间)。很抱歉我的英语不好。因此,请在插入之前检查您的数据集,并借助
Select
like is in my previous link。这样行吗?另外,
foglalas
中的
time
列的数据类型是什么?foglalas中的time是nvarchar。很难比较两个文本,我不明白怎么做,你链接了什么,我认为对我的问题不好。我已经试着解释了如何使用
Select
作为答案。