用户代码未处理 sqlexception 关键字 'file' 附近有语法错误。
我想通过gridview查看详细的信息,但是显示如上错误,我另外一个页面同样的代码,却是对的,为什么这个会报错?如下是我的代码:
Label1.Text = Session("tname").ToString()
Dim t As String
t = Choose(Weekday(Now), "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")
Label6.Text = "今天是:" & Now & Space(3) & t
myconn = New SqlConnection("server=localhost;database=database;uid=sa;pwd=sa")
myconn.Open()
Dim strfn As String = Request.QueryString("filename")
If Not String.IsNullOrEmpty(strfn) Then
Dim sqlstr As String = "select * from file where filename='" + strfn + "'"
Dim sda As New SqlDataAdapter(sqlstr, myconn)
ds = New DataSet
sda.Fill(ds, "file") 报错
Dim drv As DataRowView
drv = ds.Tables("file").DefaultView(0)
Label2.Text = Convert.ToString(drv.Row("filename"))
Label3.Text = Convert.ToString(drv.Row("filetime"))
Label4.Text = Convert.ToString(drv.Row("sname"))
TextBox1.Text = Convert.ToString(drv.Row("filecontent"))
End If
myconn.Close()
End Sub
[解决办法]