我现在做一个客户登陆验证程序,客户资料在数据库内。
但不是做
是windows应用程序
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 = "Persist Security Info=False;" _ + "Integrated Security=SSPI;database=HICAP;" _ + "server=zg10;Connect Timeout=30" 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(Me.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