当前位置: 网学 > 编程文档 > VB > 正文

VB与数据连接的心得

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式

set conn=New ADODB.Connection
set rs=New adodb.recordset
本机名称:jszx3-11
server:jszx3-11
database:wzc
uid=sa
pwd=
driver={sql server}

''定义ADO数据库对象
conn.ConnectionString = "driver={SQL Server};" & _
"server=" & ServerName & ";uid=" & UserName & ";
pwd=" & Password & ";database=" & DatabaseName & ""
''连接数据串

Private Sub Command1_Click(Index As Integer)
Dim m As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={SQL Server};server=JSZX3-11;uid=sa;pwd=;database=wzc"
conn.Open
rs.Open "select 用户名,密码 from login where 用户名=''" & Trim(Combo1.Text) & "'' And 密码=''" & Trim(Text1.Text) & "''", conn, adOpenStatic, adLockReadOnly, adCmdText
If rs.EOF = True And rs.BOF Then
m = MsgBox("请重新登录", vbExclamation)
Text1.Text = ""
Text1.SetFocus
Else
Form1.Hide
Form2.Show
End If
rs.Close
End Sub

Private Sub Command2_Click(Index As Integer)
Form2.Show
End Sub

Private Sub Command3_Click()
Unload Form1

End Sub


Private Sub Form_Load()
Dim t As Integer
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={SQL Server};server=JSZX3-11;uid=sa;pwd=;database=wzc"
conn.Open
rs.Open "select 用户名 from login", conn, adOpenStatic, adLockReadOnly, adCmdText
Dim i As String
For t = 0 To Val(rs.RecordCount) - 1
i = Trim(rs.Fields("用户名").Value)
rs.MoveNext
Combo1.AddItem i
Next t
rs.Close

End Sub

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号