2014-06-23 25 views
-3

我正在製作一個管理公司客戶的輸入和輸出以及創建相同的應用程序,但是當我向客戶「提交」創建新客戶的表單時以下錯誤:拋出新的NotImplementedException - VB

「拋出新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

刪除'遙'的ExecuteNonQuery新NotImplementedException'()'Cmd'類的'功能 – SoftSan

回答

0

你有è RROR你的 「CMD」 變量和 「修復它」 是這樣的:

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 
相關問題