1、用odbc连接,就是在系统的odbc中配置好连接,然后在程序中引用即可。
2、采取oledb方式连接,用pb自带的数据驱动程序用oledb的方式进行连接。
连接数据库:// Profile his
SQLCA.DBMS = "MSS Microsoft SQL Server"
SQLCA.Database = "数据库名称"
SQLCA.ServerName = "."
SQLCA.LogId = "sa"
SQLCA.AutoCommit = False
SQLCA.DBParm = ""
CONNECT USING SQLCA
IF SQLCA.SQLCode <>0 THEN
MessageBox('成功','数据库连接成功!')
ELSE
MessageBox('失败','数据库连接失败!')
END IF
//定义变量
String ls_id,ls_pass,ls_type
Long ll_number,i
ls_id = sle_user.Text
ls_pass = sle_pass.Text
//==============================================================================
// 判断用户名及用户密码是否正确,打开主窗口
//==============================================================================
IF ls_id = '' THEN
MessageBox('提示','用户代码为空,请重新输入!')
sle_user.SetFocus()
RETURN
END IF
SELECT count(*) INTO :ll_number FROM login Where id = :ls_id AND Password = :ls_pass
IF ll_number >0 THEN
SELECT Style INTO :ls_type FROM login Where id = :ls_id
gs_id = ls_id
gs_type = ls_type
Open(w_main)
Close(w_login)
ELSE
IF i <= 2 THEN
MessageBox('错误','密码错误,请重新输入!')
sle_pass.Text = ""
sle_pass.SetFocus()
i++
ELSE
MessageBox("警告!","输入用户口令的错误次数超过3次!")
Close(w_login)
END IF
END IF
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)