|
本帖最后由 ty_1029 于 2009-7-13 14:34 编辑
方法很多,你可以通过VBA做个ODBC的连接,这样,就很操作本地一样,当然,代码很麻烦,网上有个国外的人写了一段,是连接ORACLE的,但连接SQLserver也是一样,修改几个地方就可以了.
另外,通过ADO或者DAO,读取SQL表的记录,然后进行代码赎值就可以了.
我给你提供个ADO的吧~~
- Dim cn As New ADODB.Connection
- Dim rs As New ADODB.Recordset
- Dim strCn As String, strSQL As String
- strCn = "Provider=sqloledb;Server=(local);Database=CRM;Uid=sa;Pwd=;"
- cn.Open strCn
- strSQL = "select * from CRM.dbo.login where sno='" & Me.UserName.Value & "' or psnam='" & Me.UserName.Value & "'"
- rs.Open strSQL, cn, adOpenDynamic, adLockPessimistic
- If Me.Password = rs!psword Then
- ...........................
- rs.close
- set rs=nothing
复制代码 |
|