问题描述
我正在使用SQL查询
我尝试了此代码,但失败了
这是控制器代码
public ActionResult xternal(string Datecall)
{
DataTable dt = new DataTable();
string str = "Data Source=MAHGOUBND4;Initial Catalog=CTC_Mahgoub;Persist Security Info=True;User ID=sa;Password=ah987987987;";
using (sqlConnection cn = new sqlConnection(str))
{
using (sqlCommand cmd = new sqlCommand(" SELECT EmployeeName,COUNT(EmployeeName) as 'Duplecated' FROM [dbo].[cs] WHERE Datecall LIKE '%" +Datecall.Tostring()+ "%' GROUP BY EmployeeName HAVING COUNT(EmployeeName) > 1; "))
{
cmd.Connection = cn;
using (sqlDataAdapter da = new sqlDataAdapter(cmd))
{
da.Fill(dt);
}
}
}
return View(dt);
}
这是我的查看代码
我的代码有问题,我想补偿文本Datecall中的数据表值Datecall我该怎么做
这是查看代码
@using System.Data
@model DataTable
<input type="text" name="date" id="Datecall" placeholder="Date" required="" />
<input type="button" id="btnsearch" name="btnsearch" value="Chart" style="color:green" />
<table cellpadding="5" id="employeeTable" cellspacing="5" border="1">
<tr style="background-color:aliceblue">
<th>EmployeeName</th>
<th>Duplecated</th>
</tr>
@foreach (DaTarow dr in Model.Rows)
{
<tr>
<td>@dr["EmployeeName"]</td>
<td>@dr["Duplecated"]</td>
</tr>
}
</table>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)