开发者

Forms inheriting from a class in vb.net

I've created a class called connector. By clicking on project and adding a class开发者_如何学C. And I want to inherit from that class in the forms But I get this error.

Base class '<baseclassname1>' specified for class '<partialclassname>' cannot be different from the base class '<baseclassname2>' of one of its other partial types`

what do I do? Here's the class named connect.vb: Imports MySql.Data.MySqlClient

Public Class connect

    Private dataAdapter As New MySqlDataAdapter()

    Dim dr As MySqlDataReader

    Dim ds As New DataSet
    Dim con As New MySql.Data.MySqlClient.MySqlConnection
    Dim dsNewRow As DataRow
    Dim cmd As MySqlCommand
    Dim cn As MySqlConnection
    Dim da As MySql.Data.MySqlClient.MySqlDataAdapter
End Class

And I'm trying to inherit it from this one, which is a form:

Public Class AdminForm

    Inherits connect


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

        cn = New MySqlConnection("Server=localhost; Database=testing;Uid=root;Pwd=password;")
        'provider to be used when working with access database
        cn.Open()
        cmd = New MySqlCommand("select * from student", cn)
    End Sub
End Class

Please help


.NET does not support multiple inheritance. Your form (WinForm or ASP.NET) already derives from a base class which means that you cannot have it derived from your base class. The actions you could take to fix this problem will largely depend on what you are trying to achieve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜