线路抑制状态错误BC30451' dbo'没有宣布

时间:2017-01-20 09:58:21

标签: sql vb.net

我正在尝试创建一个新的删除按钮。新按钮有效,但我无法使用删除按钮。

代码:

Imports System.Data.SqlClient
Public Class AssetCategory
    Dim cn As New SqlConnection("Data Source=DESKTOP-PHILIP\SQLEXPRESS;Initial Catalog=PECS_Asset;Integrated Security=True")
    Dim cmd As New SqlCommand
    Dim dir As SqlDataReader
    Private txtupdatename As Object

    Private Sub AssetCategoryBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
        Me.Validate()
        Me.TableAdapterManager.UpdateAll(Me.PECS_AssetDataSet)
        cmd.Connection = cn

    End Sub

    Private Sub AssetCategory_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'PECS_AssetDataSet.AssetCategory' table. You can move, or remove it, as needed.
        Me.AssetCategoryTableAdapter.Fill(Me.PECS_AssetDataSet.AssetCategory)

    End Sub

    Private Sub ReturnToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ReturnToolStripMenuItem.Click
        Me.Hide()
        Form1.Show()

    End Sub

    Private Sub MenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub

    Private Sub AssetsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AssetsToolStripMenuItem.Click
        Me.Hide()
        Form1.Show()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
        Me.Validate()
        Me.AssetCategoryBindingSource.AddNew()
        Me.TableAdapterManager.UpdateAll(Me.PECS_AssetDataSet)
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

        Try
            Me.AssetCategoryBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.PECS_AssetDataSet)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


    Private Sub btnDelete_Click(sender As Object, e As EventArgs)
        If MsgBox("Are you sure you want to delete this record?", MsgBoxStyle.YesNo, Title:="CONFIRM") - vbYes Then

        Else
            TableAdapterManager.UpdateAll([dbo].[AssetCategory])
        End If
    End Sub
End Class

0 个答案:

没有答案