本文介绍了system.data.dll中出现未处理的'system.data.sqlclient.sqlException'类型的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Imports System.Data
Imports System.Data.SqlClient


Public Class LoginForm1

    Dim da As SqlDataAdapter
    Dim ds As DataSet
    Dim query As String
    Dim sqlq As String

    Private Sub DELETETIME()
        If con.State = ConnectionState.Open Then con.Close()
        con.Open()


        query = "DELETE FROM USERLOG WHERE USERID='" & USERNAME & "'"

        COMMAND = New SqlCommand(query, con)
        COMMAND.ExecuteNonQuery()

    End Sub



    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim CMD As SqlCommand
        If con.State = ConnectionState.Open Then con.Close()
        con.Open()

        query = "select * from USERLOGIN where USERID='" & txtUsername.Text & "'and UPASSWORD='" & txtPasswd.Text & "'"

        da = New SqlDataAdapter(query, con)
        ds = New DataSet
        da.Fill(ds)
        If ds.Tables(0).Rows.Count > 0 Then
            'valid user
            USERNAME = txtUsername.Text

            USERTYPE = ds.Tables(0).Rows(0).Item(3)
            logintime = Now
            DELETETIME()

            If con.State = ConnectionState.Open Then con.Close()
            con.Open()

            'query = "UPDATE USERLOG SET ULOGDATE='" & Today & "',ULOGINTIME='" & Now & "' WHERE USERID='" & USERNAME & "'"
            query = "INSERT INTO USERLOG VALUES('" & txtUsername.Text & "','" & Today & "','" & Now.TimeOfDay.ToString & "')"

            CMD = New SqlCommand(query, con)
            CMD.ExecuteNonQuery()


            con.Open()


            con.Close()


            frmMDIMain.Show()
            Me.Hide()


        Else
            MsgBox("INVALID LOGIN")

        End If

        txtUsername.Text = ""
        txtPasswd.Text = ""
        txtUsername.Focus()


    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Me.Close()
        End
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        txtUsername.Text = ""
        txtPasswd.Text = ""
        txtUsername.Focus()

    End Sub

    Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call myConnection()
        txtUsername.Focus()

    End Sub


End Class









当我运行它时,
。system.data.dll中出现'system.data.sqlclient.sqlException'类型的未处理异常获得了此运行时错误。



我怎么能超过这个?






when I run it."AN unhandled exception of type 'system.data.sqlclient.sqlException' occured in system.data.dll" this run time error is obtained.

how can I over come from this??

推荐答案


这篇关于system.data.dll中出现未处理的'system.data.sqlclient.sqlException'类型的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 00:36