| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 406 人关注过本帖
标题:高手帮帮忙,诚挚感谢!!!
只看楼主 加入收藏
wudihappy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-14
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
高手帮帮忙,诚挚感谢!!!
中出现:
未处理的“System.InvalidOperationException”类型的异常出现在 w.exe 中。

其他信息: 创建窗体时出错。有关详细信息,请参阅 Exception.InnerException。错误为: 未将对象引用设置到对象的实例。
界面log1代码如下:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlConnection
Imports System.Data.SqlClient.SqlDataReader
Public Class log1
    Inherits System.Windows.Forms.Form

    Dim myreader = SqlCommand1.ExecuteReader()

    Function user() As Boolean
        SqlConnection1.Open()
        SqlCommand1 = New SqlCommand("SELECT * FROM 用户信息 WHERE 用户名= '" & TextBox1.Text & "'", SqlConnection1)
        myreader = SqlCommand1.ExecuteReader()
        Dim TempString As String
        Dim type As String
        While myreader.Read
            TempString = myreader("用户密码")
            type = myreader("用户类型")
        End While
        SqlConnection1.Close()
        myreader.Close()
        SqlCommand1.Dispose()
        If TextBox2.Text = TempString And ComboBox1.Text = type Then
            Return True
        Else
            If TextBox2.Text <> TempString And ComboBox1.Text <> type Then
                Return False
            End If
        End If
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim main As New Form()
        If TextBox1.Text = "" Or TextBox2.Text = "" Or ComboBox1.Text = "" Then
            MsgBox("请输入相应信息!", MsgBoxStyle.Information, "超市管理系统")

        ElseIf TextBox1.Text <> "" And TextBox2.Text <> "" And ComboBox1.Text <> "" And user() = True Then
            main.Show()
        Else
            MsgBox("密码不正确或管理员信息不匹配!")
        End If
    End Sub

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



界面 main代码如下:
Public Class main
    Inherits System.Windows.Forms.Form


    Private Sub ToolStripLabel6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel6.Click

    End Sub

    Private Sub ToolStripLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel1.Click
        Dim log1 As New Form()
        log1.Show()
        Me.Close()

    End Sub

    Private Sub ToolStripLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.Click
        用户管理.Show()
    End Sub

    Private Sub ToolStripLabel4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel4.Click
        入库.show()
    End Sub

    Private Sub ToolStripLabel3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel3.Click
        出库.show()
    End Sub

    Private Sub ToolStripLabel5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel5.Click
        查询.show()
    End Sub

    Private Sub ToolStripLabel7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel7.Click
        关于.show()
    End Sub

    Private Sub ToolStripLabel8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel8.Click
        End
    End Sub

    Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If = "普通员工" Then
            ToolStripLabel2.Enabled = False
            ToolStripLabel3.Enabled = False
            ToolStripLabel4.Enabled = False
            用户报表ToolStripMenuItem.Enabled = False
        End If
        If = "普通管理员" Then
            ToolStripLabel2.Enabled = False
            用户报表ToolStripMenuItem.Enabled = False
        End If
        If = "进货员" Then
            ToolStripLabel2.Enabled = False
            ToolStripLabel4.Enabled = False
            用户报表ToolStripMenuItem.Enabled = False
        End If
        If = "提货员" Then
            ToolStripLabel2.Enabled = False
            ToolStripLabel3.Enabled = False
            用户报表ToolStripMenuItem.Enabled = False
        End If
    End Sub

    Private Sub 用户报表ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 用户报表ToolStripMenuItem.Click
        用户报表.show()

    End Sub

    Private Sub 商品信息表ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 商品信息表ToolStripMenuItem.Click
        商品信息表.show()
    End Sub

    Private Sub 出库报表ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 出库报表ToolStripMenuItem.Click
        出库报表.show()
    End Sub
End Class
搜索更多相关主题的帖子: 感谢 
2010-04-17 16:51
快速回复:高手帮帮忙,诚挚感谢!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049381 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved