sql-server - 重载解析失败,因为在没有缩小转换的情况下无法调用可访问的 'new'

标签 sql-server vb.net sql-server-2008

我有一个问题。

我收到这个错误:

Overload resolution failed because no accessible 'new' can be called without a narrowing conversion.

Private Sub bt_hapus_Click(sender As Object, e As EventArgs) Handles bt_hapus.Click
        Try
            Dim sqlda As New SqlClient.SqlDataAdapter("Delete from tblpasien where No_Rkm_Mds=" & Me.No_Rkm_MdsTextBox.Text, Me.KlinikGigiDataSet)
            sqlda.Fill(dbpasien, "tblpasien")
            MsgBox("Data telah berhasil dihapus")
            bersih()
            pasif()
            normal()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

所有源代码:

Public Class frm_pasien
    Dim dbpasien As New DataSet
    Dim dvpasien As New DataView
    Dim tekan As Integer
    Dim cari As Integer

    Private Sub TblpasienBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TblpasienBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.TblpasienBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.KlinikGigiDataSet)

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'KlinikGigiDataSet.tblpembayaran' table. You can move, or remove it, as needed.
        Me.TblpembayaranTableAdapter.Fill(Me.KlinikGigiDataSet.tblpembayaran)
        'TODO: This line of code loads data into the 'KlinikGigiDataSet.tblpasien' table. You can move, or remove it, as needed.
        Me.TblpasienTableAdapter.Fill(Me.KlinikGigiDataSet.tblpasien)

    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click

    End Sub

    Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click

    End Sub

    Private Sub bt_keluar_Click(sender As Object, e As EventArgs) Handles bt_keluar.Click
        Dim pesan As DialogResult = MsgBox("Apakah anda yakin akan keluar", MsgBoxStyle.OkCancel)
        If pesan = DialogResult.OK Then
            Me.Close()
        Else
            Exit Sub
        End If
    End Sub


    Private Sub bt_hapus_Click(sender As Object, e As EventArgs) Handles bt_hapus.Click
        Try
            Dim sqlda As New SqlClient.SqlDataAdapter("Delete from tblpasien where No_Rkm_Mds=" & Me.No_Rkm_MdsTextBox.Text, Me.KlinikGigiDataSet)
            sqlda.Fill(dbpasien, "tblpasien")
            MsgBox("Data telah berhasil dihapus")
            bersih()
            pasif()
            normal()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub bersih()
        Me.No_Rkm_MdsTextBox.Clear()
        Me.NamaTextBox.Clear()
        Me.UmurTextBox.Clear()
        Me.Tgl_LhrTextBox.Clear()
        Me.AlamatTextBox.Clear()
        Me.No_HpTextBox.Clear()
        Me.No_Rkm_MdsTextBox.Focus()
    End Sub

    Private Sub pasif()
        Me.No_Rkm_MdsTextBox.Enabled = False
        Me.NamaTextBox.Enabled = False
        Me.UmurTextBox.Enabled = False
        Me.Tgl_LhrTextBox.Enabled = False
        Me.AlamatTextBox.Enabled = False
        Me.No_HpTextBox.Enabled = False
    End Sub

    Private Sub normal()
        Me.bt_tambah.Enabled = True
        Me.bt_edit.Enabled = True
        Me.bt_simpan.Enabled = False
        Me.bt_reset.Enabled = False
        Me.bt_hapus.Enabled = False
        Me.bt_keluar.Enabled = True
    End Sub
    Private Sub binding()
        Me.No_Rkm_MdsTextBox.DataBindings.Clear()
        Me.No_Rkm_MdsTextBox.DataBindings.Add("Text", dvpasien, "Id")
        Me.NamaTextBox.DataBindings.Clear()
        Me.NamaTextBox.DataBindings.Add("Text", dvpasien, "Nama")
        Me.UmurTextBox.DataBindings.Clear()
        Me.UmurTextBox.DataBindings.Add("Text", dvpasien, "Alamat")
        Me.Tgl_LhrTextBox.DataBindings.Clear()
        Me.Tgl_LhrTextBox.DataBindings.Add("Text", dvpasien, "Ttl")
        Me.AlamatTextBox.DataBindings.Clear()
        Me.AlamatTextBox.DataBindings.Add("value", dvpasien, "Jkl")
        Me.No_HpTextBox.DataBindings.Clear()
        Me.No_HpTextBox.DataBindings.Add("Text", dvpasien, "Pekerjaan")
    End Sub

    Private Sub No_Rkm_MdsTextBox_TextChanged(sender As Object, e As EventArgs) Handles No_Rkm_MdsTextBox.TextChanged
        If Len(Me.No_Rkm_MdsTextBox.Text) < 10 Then
            Exit Sub
        End If
        dvpasien.Sort = "Id"
        Try
            cari = dvpasien.Find(Me.No_Rkm_MdsTextBox.Text)
            If cari = -1 Then
                If tekan = 1 Then
                    Me.No_Rkm_MdsTextBox.Focus()
                Else
                    MsgBox("Data tidak ada")
                    bersih()
                End If

            Else
                If tekan = 1 Then
                    MsgBox("Data sudah ada")
                    bersih()
                Else
                    binding()
                    tampilgrid()
                    Me.bt_edit.PerformClick()
                End If

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub tampilgrid()
        Throw New NotImplementedException
    End Sub    
End Class

请帮忙,这是我的讲师写的论文。

最佳答案

您是否使用 New 关键字声明了您的数据集

含义如下:

Dim dbpasien As New DataSet()

或者

Using dbpasien As DataSet = New DataSet()

关于sql-server - 重载解析失败,因为在没有缩小转换的情况下无法调用可访问的 'new',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18781120/

相关文章:

c# - .Net 中的零舍入错误类?

.net - .NET 中属性的嵌套类访问方法

sql - sp_whoisactive 导致未知查询 : "Insert Into <table_name> select *,%%bmk%% from <table_name> option (maxdop 1)"

sql-server - 为什么 MyGeneration 存储过程生成器模板不起作用?

sql-server - SQL Server 2000 - 如何在查询的最终结果中轮换联接结果?

c# - 在 C# 中获取数据库字段名称数组?

c# - 嵌套和非嵌套 else/else ifs 之间有区别吗?

c# - 林克 : How to store MD5 hash column in database

php - 如何获取PHP中的SQL Server触发器错误?

c# - 在 C# 中验证小数以在 SQL Server 中存储