vb.net 被指定为此窗体的 MdiParent 的窗体不是 MdiContainer。 参数名: value
Private Sub 用户管理UToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 用户管理UToolStripMenuItem.Click
userinfo.MdiParent = Me
userinfo.Show()
End Sub
出现上面异常怎么处理
调用函数为Imports System.Data
Imports System.Data.SqlClient
Imports System.ComponentModel
Public Class DataBase
'实现接口IDisposable
Implements IDisposable
'数据库连接对象
Private SqlConn As SqlConnection
Public Shared sConn As String = "Data Source=2011-20120208VD;Initial Catalog=HotelCX;Integrated Security=True"
Public Sub Dispose() Implements System.IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(True)
End Sub
Protected Sub Dispose(ByVal disposing As Boolean)
If disposing <> True Then
Return
End If
If SqlConn Is Nothing = False Then
SqlConn.Dispose()
SqlConn = Nothing
End If
End Sub
Public Sub Open()
If SqlConn Is Nothing = True Then
'建立数据库连接对象
SqlConn = New SqlConnection(DataBase.sConn)
'打开数据库连接
SqlConn.Open()
End If
End Sub
Public Sub Close()
'如果数据库连接对象不为空则关闭数据库连接
If SqlConn Is Nothing = False Then
SqlConn.Close()
End If
End Sub
Public Function RunSelectSQL(ByVal sSQLString As System.String) As DataView
Me.Open()
Dim SqlDS As DataSet = New DataSet
Dim SqlDA As SqlDataAdapter = New SqlDataAdapter(sSQLString, Me.SqlConn)
SqlDA.Fill(SqlDS)
Return SqlDS.Tables(0).DefaultView
End Function
Public Function RunDelOrInsSQL(ByVal sSQLString As System.String)
Me.Open()
Dim SqlComm As SqlCommand = New SqlCommand(sSQLString, Me.SqlConn)
SqlComm.ExecuteNonQuery()
End Function
End Class
[解决办法]
父窗口的IsMdiContainer属性设为True