本文介绍了怎么能在列表框中看到总veichle赋值日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我创建了一个表城市,veichle,assigndate,我在其中插入值但我怎样才能在列表框中看到 i在网络表单上有日历和列表框,我的代码是.... I have create one table city, veichle,assigndate where i insert value but how can i see on listboxi have calender and listbox on web form and my code is....SqlCommand cmd = new SqlCommand("select count(*)as from Assvechle where assdate='"+calenderid.SelectedDate +"' ", con); SqlDataReader dr = cmd.ExecuteReader(); ListBox1.DataSource = dr; ListBox1.DataTextField = "total"; ListBox1.DataTextField = "city"; ListBox1.DataValueField = ""; ListBox1.DataBind(); con.Close(); } 有错误there is error推荐答案 SqlCommand cmd = new SqlCommand("select count(*)as from Assvechle where assdate='"+calenderid.SelectedDate +"' ", con);成为: Becomes:SqlCommand cmd = new SqlCommand("select count(*) from Assvechle where assdate='"+calenderid.SelectedDate +"' ", con); 但请使用参数化查询!But please, use a parameterized query! CREATE PROCEDURE GetCountOfCityOnDate @assdate DATETIMEASBEGIN SELECT city, count(*) AS Total FROM Assvechle WHERE assdate = @assdate GROUP BY cityEND 如需了解更多信息,请参阅: 如何:保护ASP.NET中的SQL注入 [ ^ ] 在停止之前停止SQL注入攻击 [ ^ ] SQL注入及其如何避免 [ ^ ] 演练:使用GridView Web服务器控件中的存储过程显示数据 [ ^ ] 如何:执行返回行的存储过程 [ ^ ] 如何使用Visual Basic .NET在ASP.NET中调用SQL Server存储过程 [ ^ ] For further information, please see:How To: Protect From SQL Injection in ASP.NET[^]Stop SQL Injection Attacks Before They Stop You[^]SQL Injection and how to avoid it[^]Walkthrough: Displaying Data Using a Stored Procedure in the GridView Web Server Control[^]How to: Execute a Stored Procedure that Returns Rows[^]How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET[^] 这篇关于怎么能在列表框中看到总veichle赋值日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 13:26