为什么只显示标题,而没有查询结果?请指教!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
SqlDataAdapter1.Fill(DataSet11)
DataGrid1.DataSource = DataSet11.Tables("table1")
DataGrid1.DataBind()
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strvalue As String = Trim(TextBox1.Text)
If strvalue <> "" Then strvalue = "%" & strvalue & "%"
DataSet11.Tables("table1").Clear()
Dim strsql As String
Select Case DropDownList1.SelectedItem.Value
Case "课程代码"
strsql = "select * from table where 课程代码 like 'strvalue'"
SqlDataAdapter1.Fill(DataSet11, strsql)
DataGrid1.DataSource = DataSet11.Tables("table")
DataGrid1.DataBind()
Case "课程名称"
strsql = "select * from table where 课程名称 like 'strvalue'"
SqlDataAdapter1.Fill(DataSet11, strsql)
DataGrid1.DataSource = DataSet11.Tables("table")
DataGrid1.DataBind()
End Select
End Sub