使用添加查询选项,用平时的SQL语句写法,select * from jewels where name like '" & iId & "%' ,,,,为什么查询结果会是空,,在formload里有写,iId="d"我把变量换成常量就正常,返回我要的结果
select * from jewels where name like 'd%'
语法问题?还是?
用了msgbox检测变量是否正确赋值了,结果返回正确
Public Class frmMain
Dim iID As String
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.JewelsTableAdapter.Fill(Me.LoxDataSet.jewels)
iID = "d"
End Sub
Private Sub SearchToolStripButton_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchToolStripButton.Click
MsgBox(iID)
Try
Me.JewelsTableAdapter.Search(Me.LoxDataSet.jewels)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
End Class