标题:请看看我的代码(sql server的问题)
只看楼主
座间翔
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-3-17
 问题点数:0 回复次数:2 
请看看我的代码(sql server的问题)

Option Explicit
Dim sqlstr As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
----------------------------------------------------------------
Private Sub cmdclose_Click()
Unload Me
End Sub
--------------------------------------------------------------
Private Sub cmdok_Click()
Dim sqlstr1 As String
sqlstr1 = "select * from login_用户 where 用户名='" & txt_用户名.Text & "'"

conn.Open sqlstr1
If Not conn.EOF Then
MsgBox "用户名错误!", vbInformation
Exit Sub
End If
If txt_密码.Text = conn.密码 Then
frmmain.Show
upload
End If
Else
MsgBox "用户名或密码错误!"
Exit Sub
End If
End Sub

Private Sub Form_Load()
'连接sql server

sqlstr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;passwore=52125212;Initial Catalog=zjx;Data Source=YSL"

End Sub

================================================================
我和sql server连上了,请高手帮小弟我看看打开数据库方法对吗?这是个用户登陆界面~!

搜索更多相关主题的帖子: sql server 代码 
2006-03-24 14:59
wsn
Rank: 2
等 级:新手上路
威 望:5
帖 子:321
专家分:0
注 册:2006-2-9
得分:0 

Option Explicit
Dim sqlstr As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
----------------------------------------------------------------
Private Sub cmdclose_Click()
Unload Me
End Sub
--------------------------------------------------------------
Private Sub cmdok_Click()
Dim sqlstr1 As String
sqlstr1 = "select * from login_用户 where 用户名='" & txt_用户名.Text & "'"

conn.Open sqlstr
set rs=conn.execute(sqlstr1)
If Not rs.EOF Then
MsgBox "用户名错误!", vbInformation
Exit Sub
End If
If txt_密码.Text = rs!密码 Then
frmmain.Show
upload
End If
Else
MsgBox "用户名或密码错误!"
Exit Sub
End If
End Sub

Private Sub Form_Load()
'连接sql server

sqlstr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;passwore=52125212;Initial Catalog=zjx;Data Source=YSL"

End Sub

随手改改,没调试


已婚男人!没事请勿打扰·老婆格言:①不准對她耍酷 ②不准讓她吃醋 ③吵架我要讓步 ④揍我我要挺住⊙⊙
2006-03-24 16:53
座间翔
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-3-17
得分:0 

谢谢了,朋友.

2006-03-24 17:55



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




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

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