问题描述
我在代码中出现错误,错误是语法错误:''*''运算符之前缺少操作数.我正在使用Visual Studio 2005和sql 2005数据库
请给我建议.在这里我附上代码.在此代码中,我尝试使用按钮,在数据库(表名称staff)中使用列= NAME和文本框作为用户输入
私有Sub Search_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理btnsearch.Click
Me.StaffBindingSource.Filter ="NAME = *"& Me.txtsearch.Text& "
结束子
非常感谢..对于每个人.这太棒了.....它确实有效.bye
hai i got an error in my code which is Syntax error: Missing operand before ''*'' operator. i am using visual studio 2005 and sql 2005 database
.please advice please. here i attach the code.In this code i try to use button the search data in database( table name staff) using a column =NAME and text box as user input
private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Me.StaffBindingSource.Filter = "NAME = *" & Me.txtsearch.Text & ""
End Sub
Thank a lot..for everyone.it was fantastic.....it really work .bye
推荐答案
private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Me.StaffBindingSource.Filter = "NAME LIKE '%" & Me.txtsearch.Text & "'";
End Sub
供您参考
探索BindingSource筛选器的秘密 [ ^ ]
使用BindingSource和DataView过滤在DataGridView中显示的数据 [ ^ ]
For your information
Exploring Secrets of BindingSource Filters[^]
Filter data dispalyed in a DataGridView using BindingSource and DataView[^]
Me.StaffBindingSource.Filter = "NAME = '%" & Me.txtsearch.Text & "'"
将查找所有以txtsearch结尾的名称.
这个:
Will find all names that end with whatever is in txtsearch.
This:
Me.StaffBindingSource.Filter = "NAME = '" & Me.txtsearch.Text & "%'"
将查找所有以txtsearch开头的名称.
如果您正在寻找除此以外的其他内容,请描述您要完成的工作,我们将尽力提供帮助.
Will find all names that begin with whatever is in the txtsearch.
If you are looking for something other than these, please describe what you want to accomplish and we will try to help.
Public Class Admin
Private Sub StaffBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StaffBindingNavigatorSaveItem.Click
Me.Validate()
Me.StaffBindingSource.EndEdit()
Me.StaffTableAdapter.Update(Me.LoginDataSet.staff)
End Sub
Private Sub Admin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LoginDataSet.staff' table. You can move, or remove it, as needed.
Me.StaffTableAdapter.Fill(Me.LoginDataSet.staff)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Me.StaffBindingSource.Filter = "NAME = %" & Me.txtsearch.Text & ""
End Sub
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
End Sub
Private Sub btnlogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogout.Click
Login.Show()
End Sub
End Class
这篇关于语法错误非异常句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!