标题:求助sqlserver2000数据库连接方法???
只看楼主
chj18888
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-6-22
 问题点数:0 回复次数:2 
求助sqlserver2000数据库连接方法???
如何连接查询数据库?
我现在做一个客户登陆验证程序,客户资料在数据库内。
但不是做
是windows应用程序
搜索更多相关主题的帖子: 数据库 
2005-06-22 13:12
JJM
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-7-9
得分:0 

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


2005-07-09 16:41
wuhui
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-12-2
得分:0 
我是一个新手,请各位师兄多多指教!!!!!!!!!!!

2005-12-02 11:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-21354-1-1.html




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

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