语法错误非异常句柄 [英] Syntax Error unexception handles

查看:110
本文介绍了语法错误非异常句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中出现错误,错误是语法错误:''*''运算符之前缺少操作数.我正在使用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

推荐答案

您的代码有误.

  • 您应该使用%而不是*
  • 您应该在该行中使用关键字LIKE
  • 您应该放置''(单引号),因为您正在搜索字符串搜索
Your code is wrong.

  • You should use % instead of *
  • You should use the keyword LIKE in that line
  • You should put ''(single quote) because you are searching string search
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[^]


您仍然缺少单引号...但是您希望过滤器如何工作?这个:
You are still missing the single quotes...but how do you want the filter to work? This:
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.


抱歉,它仍然出错(语法错误:之前缺少操作数"Mod"运算符.)再次提出任何解决方案...我也没有任何想法

Sorry bro...it still error(Syntax error: Missing operand before ''Mod'' operator.) Any solution again...i also dont have any idea

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


这篇关于语法错误非异常句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆