我使用Vb.net 2012與SQL作爲反手。 這是我的SQL Server數據庫表的名稱是「時間表」像谷歌搜索引擎的SQL桌面應用程序
__________________________ Name | Course | _____|___________________| a | DTP Flash AutoCad |(All these are courses with space between each courses) b | PHP Asp C# | c | Flash WebDesigning| _____|___________________|
我運行該SQL查詢
Private Sub TxtName_TextChanged(sender As Object, e As EventArgs) Handles TxtName.TextChanged
Try
Dim txt As Integer = Val(Len(TxtName.Text))
MsgBox(Val(txt))
Dim str As String = "select FName, SurName,Courses,TotalFees,Balance,TotalDuration,DOA,DOC,Status,Time,ContactNo,ONo from TimeTable where FName='" & TxtName.Text & "' or Courses= SUBSTRING('" & TxtName.Text & "',0,50)"
Dim ds As New DataSet
adp = New SqlDataAdapter(str, cn)
adp.Fill(ds)
DataGridView1.DataSource = Nothing
DataGridView1.Refresh()
DataGridView1.DataSource = ds
DataGridView1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
當名
搜索的數據顯示在GridView控件但是當我寫課程名稱與子字符串它不顯示我...我必須寫整個課程的名稱....即「DTP Flash AutoCad」。
我希望如果用戶鍵入DTP它顯示數據,即使該行包含 DTP Flash AutoCad。
作爲便箋,請見[Bobby Tables](http://stackoverflow.com/q/332365/11683)。 – GSerg