抛出新的NotImplementedException - VB

时间:2014-06-23 09:23:34

标签: vb.net

我正在创建一个管理公司客户输入和输出的应用程序以及创建相同的应用程序,但是当我向我提交新客户的表单时,会出现以下错误:< / p>

“抛出新的NotImplementedException”

我把代码留在这里,所以他们可以帮助我。

Form1.vb的

Public Class Form1

Private Property cnt As Object

<SerializableAttribute> _
'<ComVisibleAttribute(True)> _
Public Class NotImplementedException _
'Inherits SystemException


End Class




Private Sub TabPage1_Click(sender As Object, e As EventArgs)
    Dim cnt As New OleDb.OleDbConnection

End Sub

Private Sub Label1_Click(sender As Object, e As EventArgs)

End Sub

Private Sub GroupBox1_Enter(sender As Object, e As EventArgs)

End Sub

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
    TabControl1.SelectedTab = TabPage2
End Sub

Private Sub TabPage2_Click(sender As Object, e As EventArgs) Handles TabPage2.Click

End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'cnt.ConnectionString = "Provinder=Microsoft.Jet.Oledb.40; Data Source=" & Application.StartupPath & "\bdtesteentradas.mdb"
    'TODO: This line of code loads data into the 'BdtesteentradasDataSet.empresa' table. You can move, or remove it, as needed.
    Me.EmpresaTableAdapter.Fill(Me.BdtesteentradasDataSet.empresa)

End Sub

Private Sub FillByToolStripButton_Click(sender As Object, e As EventArgs) Handles FillByToolStripButton.Click
    Try
        Me.EmpresaTableAdapter.FillBy(Me.BdtesteentradasDataSet.empresa)
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try

End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    Me.EmpresaBindingSource.Filter = "nif ='" & TextBox1.Text & "'"

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox6.Text = ""
    TextBox7.Text = ""
    TextBox8.Text = ""
    TextBox5.Text = ""
    TextBox4.Text = ""

End Sub

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click



    'Dim cnt As New OleDb.OleDbCommand
    If Not ConnectionState.Open Then

    End If

    Cmd.Connection = cnt()
    Cmd.CommandText = "INSERT INTO empresa (NIF, Empresa, nCliente, Distrito, NomeContacto, ApelidoContacto, Funcao" &
      "VALUES(" & Me.TextBox6.Text & ")"
    'Cmd.ExecuteNonQuery()

    MsgBox("Dados inseridos.")




End Sub

Cmd.vb

Class Cmd

Shared Property CommandText As String

Shared Property Connection As Object
Shared Sub ExecuteNonQuery()
    Throw New NotImplementedException
End Sub

结束班

Error message

已经非常感谢你了

1 个答案:

答案 0 :(得分:0)

你的&#34; cmd&#34;变量和&#34;修复它&#34;这样:

fix1 fix2

你不是吗?这为您生成了文件Cmd.vb

这不是你想要的。从您的项目中删除Cmd.vb,请尝试以下操作:

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        'You want to check, what the State of *your* connection is
        If Not cnt.State = ConnectionState.Open Then

        End If

        'Create a Command-Object from the Connection
        Using cmd = cnt.CreateCommand()
            cmd.CommandText = "INSERT INTO empresa (NIF, Empresa, nCliente, Distrito, NomeContacto, ApelidoContacto, Funcao" &
              "VALUES(" & Me.TextBox6.Text & ")"
            cmd.ExecuteNonQuery()

            MsgBox("Dados inseridos.")

        End Using

    End Sub