点击查询按钮时出错:sql从字符串向 datetime 转换时失败.怎么修改?求指点,
代码如下:ProtectedSubButton1_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesBu...
代码如下: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As SqlConnection
Dim constr As String
constr = "server=jy-201412271109;database=MyDB;uid=sa;pwd="
conn = New SqlConnection(constr)
conn.Open()
Dim sql As String
Dim m As String = "this starttime.value.ToString"
Dim n As String = "this endtime.value.ToString"
sql = "select * from Table_1 where addtime between'" & m & "' and '" & n & "'"
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, conn)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
conn.Close()
我使用的是My97datepicker日历控件,想查询选中的起始时间到结束时间段之间的数据,并用Gridview1显示出来,该怎么做? 展开
Dim conn As SqlConnection
Dim constr As String
constr = "server=jy-201412271109;database=MyDB;uid=sa;pwd="
conn = New SqlConnection(constr)
conn.Open()
Dim sql As String
Dim m As String = "this starttime.value.ToString"
Dim n As String = "this endtime.value.ToString"
sql = "select * from Table_1 where addtime between'" & m & "' and '" & n & "'"
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, conn)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
conn.Close()
我使用的是My97datepicker日历控件,想查询选中的起始时间到结束时间段之间的数据,并用Gridview1显示出来,该怎么做? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询