首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

Message='=' 附近有语法异常

2013-04-20 
Message'' 附近有语法错误。Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Sys

Message='=' 附近有语法错误。
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim cn As New System.Data.SqlClient.SqlConnection(My.Settings.UFDATA_008_2012ConnectionString)
        Dim sql As String = "select top 1 ccusname from customer where ccuscode=" & ComboBox1.Text
        Dim command As SqlClient.SqlCommand = New SqlCommand(sql, cn)
        command.Connection.Open()
        Dim reader As SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
        Do While reader.Read
            Me.TextBox1.Text = reader.GetString(0)
        Loop
        reader.Close()
        command.Connection.Close()

    End Sub


红色标识部分提示语法错误

未处理 System.Data.SqlClient.SqlException
  Class=15
  ErrorCode=-2146232060
  LineNumber=1
  Message='=' 附近有语法错误。
  Number=102
  Procedure=""
  Server=20130408-1708
  Source=.Net SqlClient Data Provider
  State=1
  StackTrace:
       在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       在 System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       在 System.Data.SqlClient.SqlDataReader.get_MetaData()
       在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)


       在 WindowsApplication1.Form1.ComboBox1_SelectedIndexChanged(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\VB.NET\dzd\dzd\Form1.vb:行号 20
       在 System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
       在 System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
       在 System.Windows.Forms.ComboBox.OnDataSourceChanged(EventArgs e)
       在 System.Windows.Forms.ListControl.SetDataConnection(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean force)
       在 System.Windows.Forms.ListControl.DataSourceDisposed(Object sender, EventArgs e)
       在 System.ComponentModel.Component.Dispose(Boolean disposing)
       在 System.Windows.Forms.BindingSource.Dispose(Boolean disposing)
       在 System.ComponentModel.Component.Dispose()
       在 System.ComponentModel.Container.Dispose(Boolean disposing)
       在 System.ComponentModel.Container.Dispose()
       在 WindowsApplication1.Form1.Dispose(Boolean disposing) 位置 C:\Documents and Settings\Administrator\My Documents\VB.NET\dzd\dzd\Form1.Designer.vb:行号 10
       在 System.ComponentModel.Component.Dispose()
       在 System.Windows.Forms.Form.WmClose(Message& m)
       在 System.Windows.Forms.Form.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DefFrameProc(IntPtr hWnd, IntPtr hWndClient, Int32 msg, IntPtr wParam, IntPtr lParam)
       在 System.Windows.Forms.Form.DefWndProc(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
       在 System.Windows.Forms.Form.WmSysCommand(Message& m)
       在 System.Windows.Forms.Form.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DefFrameProc(IntPtr hWnd, IntPtr hWndClient, Int32 msg, IntPtr wParam, IntPtr lParam)


       在 System.Windows.Forms.Form.DefWndProc(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
       在 System.Windows.Forms.Form.WmNcButtonDown(Message& m)
       在 System.Windows.Forms.Form.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(ApplicationContext context)
       在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       在 WindowsApplication1.My.MyApplication.Main(String[] Args) 位置 17d14f5c-a337-4978-8281-53493378c1071.vb:行号 81
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 



热点排行