vb.net 中不能在此处使用参数和字符未指定的参数

Argument not specified for parameter and character cannot be used here in vb.net

我尝试从 C# 转换为 vb.net,但出现错误。有解决办法吗,我用的是visual studio 2010. 我post完整代码

谢谢 杰克

'In the insert form:
       Public Sub New(ByVal f2 As Form2)
            InitializeComponent()
            frm2 = f2
        End Sub

        Public Delegate Sub UpdateDelegate(ByVal sender As Object, ByVal args As UpdateEventArgs)
        Public Event UpdateEventHandler As UpdateDelegate
        Private frm2 As Form2

        Public Class UpdateEventArgs
            Inherits EventArgs

            Public Property Data() As String
        End Class

        Protected Sub raiseUpdate()
            Dim args As New UpdateEventArgs()
            UpdateEventHandlerEvent?.Invoke(Me, args) 'this error Argument not specified for parameter and character cannot be used
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim sqlCon As String = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\v-baf\OneDrive\MyWork\MyWinFrm\WinFormApplication20170302\WinFormApplication20170517+\DB\Database1.mdf;Integrated Security=True"

            Using conn As New SqlConnection(sqlCon)
                conn.Open()
                Using cmd As SqlCommand = conn.CreateCommand()
                    cmd.CommandText = "insert into Table1(Character, Level, Clan) values('" & textBox2.Text & "','" & textBox3.Text & "','" & textBox4.Text & "')"
                    cmd.ExecuteNonQuery()
                End Using
            End Using
            raiseUpdate()
        End Sub

我认为您需要使用:

RaiseEvent UpdateEventHandler(Me, args) 

或:

If UpdateEventHandlerEvent IsNot Nothing Then UpdateEventHandlerEvent.Invoke(Me, args)

(我怀疑你古老的 VB 不理解转换器生成的 ?. 语法)

您的活动名称可以做一些改进;考虑这样称呼它:

Public Event DataInserted As ...

此外,抛开全部,作为紧急事项阅读 http://bobby-tables.com,永远不要再像您在那里所做的那样写 SQL;它是破解具有数据库的系统的第一个简单方法