以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于数据源的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=135564)

--  作者:tuohai
--  发布时间:2019/5/29 14:44:00
--  关于数据源的问题
我使用的是阿里云服务器的sql sever数据库,希望把数据源保存在项目目录下。希望老师给个方案,本人很菜,请老师给个详细方案。
--  作者:有点甜
--  发布时间:2019/5/29 15:33:00
--  

 

不理解你的意思,为什么要把数据源保存在项目目录下?这样做的目的是什么?

 

 


--  作者:tuohai
--  发布时间:2019/5/30 10:43:00
--  
老师我是这么构想的 ,host.txt 和 host.txt 分别存储两个不同的数据源,麻烦老师帮忙看看,或者给个更好的意见。

BeforeConnectOuterDataSource


Dim h1 As String = e.ProjectPath & "host.txt"
Dim h2 As String = e.ProjectPath & "host2.txt"
If Filesys.FileExists(h1) Then
    Dim s1 As String = FileSys.ReadAllText(h1)
    If Filesys.FileExists(h2) Then
        Dim s2 As String = FileSys.ReadAllText(h2)
        If e.Name = "tuohai IT" Then
            If e.User.Group = "一店" Then
                e.ConnectionString = s1
                If e.User.Group = "二店" Then
                    e.ConnectionString = s2
                End If
            End If
        End If
    End If
End If

--  作者:有点甜
--  发布时间:2019/5/30 10:50:00
--  


Dim h1 As String = e.ProjectPath & "host.txt"
Dim h2 As String = e.ProjectPath & "host2.txt"

If e.Name = "tuohai IT" Then
    If e.User.Group = "一店" Then
        If Filesys.FileExists(h1) Then
            Dim s1 As String = FileSys.ReadAllText(h1)
            e.ConnectionString = s1
        Else
            msgbox("配置文件不存在")
        End If
    ElseIf e.User.Group = "二店" Then
        If Filesys.FileExists(h2) Then
            Dim s2 As String = FileSys.ReadAllText(h2)
            e.ConnectionString = s2
        Else
            msgbox("配置文件不存在")
        End If
    End If
End If

 


--  作者:tuohai
--  发布时间:2019/5/30 11:02:00
--  
老师这段代码好像没有执行,我把配置文件(host.txt,host2.txt)删了,也没有提示配置文件不存在。麻烦老师了!!
--  作者:有点甜
--  发布时间:2019/5/30 11:07:00
--  

Dim h1 As String = e.ProjectPath & "host.txt"
Dim h2 As String = e.ProjectPath & "host2.txt"

msgbox(e.name)

If e.Name = "tuohai IT" Then

msgbox(2)

msgbox(e.user.group)
    If e.User.Group = "一店" Then
        If Filesys.FileExists(h1) Then
            Dim s1 As String = FileSys.ReadAllText(h1)
            e.ConnectionString = s1
        Else
            msgbox("配置文件不存在")
        End If
    ElseIf e.User.Group = "二店" Then
        If Filesys.FileExists(h2) Then
            Dim s2 As String = FileSys.ReadAllText(h2)
            e.ConnectionString = s2
        Else
            msgbox("配置文件不存在")
        End If
    End If
End If


--  作者:tuohai
--  发布时间:2019/5/30 11:54:00
--  
老师,显示了数据源名称,显示了“2” ,后面的用户分组没有提示。
--  作者:有点甜
--  发布时间:2019/5/30 11:56:00
--  

e.user.group这个值,是内置的登陆窗口的用户才有用的

 

http://www.foxtable.com/webhelp/scr/0607.htm

 

如果是你自己做的登陆窗口,无法使用这个变量。


--  作者:tuohai
--  发布时间:2019/5/30 12:00:00
--  
我用的就是内置登录窗口。
--  作者:有点甜
--  发布时间:2019/5/30 12:01:00
--  

那这个弹出什么?

 

msgbox(e.user.group)

 

你给用户设置的分组是什么?