3层架构中的recordset

jett 2002-02-19 02:43:25
中间件和用户界面之间(客户端)需要传递一个recordset
但是这是在2台机器上的交互
所以我希望是先在中间件上建立一个recordset对象
然后把该recordset复制到客户端的机器上的recordset,而不是传递一个引用
应该怎么做
...全文
122 91 打赏 收藏 转发到动态 举报
写回复
用AI写文章
91 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony0115 2002-03-01
  • 打赏
  • 举报
回复
用XML吧
Brunhild 2002-03-01
  • 打赏
  • 举报
回复
mark
huater 2002-02-28
  • 打赏
  • 举报
回复
可以用soap协议、Com组件和xml数据格式建立三层架构的WEBSERVICE。可以实现。可以用VB6.0做COM组件,然后用SOAP通过防火墙去调用COM组件得到你所需要的记录集。表示层调用业务逻辑层,逻辑层再调用数据访问层,数据访问层再去对数据库操作。如有兴趣,发EMAIL到:Machel_jia@hotmail.com
progame 2002-02-28
  • 打赏
  • 举报
回复
这么执着,居然去测试了

谢谢你的测试
jett 2002-02-28
  • 打赏
  • 举报
回复
所取得数据量是4000条
可以从上面数据大致看出
用断开式记录集的确最快
不管是执行速度,还是传输速度

用xml比我想象中的还要差
当然也有可能是受到vb处理字符串效率比较低的影响

感谢各位参与,没什么新的补充的话,就结了
lijun03210321 2002-02-28
  • 打赏
  • 举报
回复
这要用到COM+建立active exe服务嚣
jett 2002-02-28
  • 打赏
  • 举报
回复
几次比较稳定的结果
Marshal time 591
performance :
Marshal connect : 0
Marshal data to rs : 125
Marshal end : 0
0
Xml time 5618
performance :
xml connect : 0
xml open rs : 109
xml rs to xml : 2063
Xml end : 15
0
getstring time 1502
performance :
getStr connect: 0
getStr data to rs : 109
getStr rs to string: 235
getStr time: 0
0
Marshal time 591
performance :
Marshal connect : 0
Marshal data to rs : 109
Marshal end : 0
0
Xml time 5908
performance :
xml connect : 16
xml open rs : 109
xml rs to xml : 2063
Xml end : 0
0
getstring time 911
performance :
getStr connect: 0
getStr data to rs : 110
getStr rs to string: 234
getStr time: 0
0
Marshal time 591
performance :
Marshal connect : 0
Marshal data to rs : 125
Marshal end : 0
0
Xml time 6840
performance :
xml connect : 0
xml open rs : 110
xml rs to xml : 2062
Xml end : 0
0
getstring time 1572
performance :
getStr connect: 0
getStr data to rs : 125
getStr rs to string: 235
getStr time: 0
0
Marshal time 580
performance :
Marshal connect : 0
Marshal data to rs : 110
Marshal end : 0
0
Xml time 6009
performance :
xml connect : 15
xml open rs : 110
xml rs to xml : 2046
Xml end : 0
0
getstring time 901
performance :
getStr connect: 0
getStr data to rs : 110
getStr rs to string: 234
getStr time: 0
jett 2002-02-28
  • 打赏
  • 举报
回复
做了几个试验,测试了几个办法的性能
结果应该能猜得到,只是大致在量上有个概念
activex dll (ProDataTransfertest.CDataTransfertest)

Private Declare Function GetTickCount Lib "kernel32" () As Long

Public Function MarGetData(ByRef ReturnRs As Recordset, ByRef PerformanceData As String) As Long
On Error GoTo errhandle
Dim ddd As Long
Dim ConnectStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim test As Long
ddd = GetTickCount
ConnectStr = ????
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
cn.Open ConnectStr

PerformanceData = "Marshal connect : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

rs.Open ????, cn, adOpenStatic, adLockReadOnly, adCmdTable
rs.ActiveConnection = Nothing

PerformanceData = PerformanceData + "Marshal data to rs : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

Set ReturnRs = rs
'rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
MarGetData = 0
PerformanceData = PerformanceData + "Marshal end : " + CStr(GetTickCount - ddd)
Exit Function
errhandle:
MarGetData = -1
End Function

Public Function XmlGetData(ByRef XmlData As String, ByRef PerformanceData As String) As Long
On Error GoTo errhandle
Dim ddd As Long
Dim ConnectStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim oStream As ADODB.Stream
ddd = GetTickCount
ConnectStr = ????
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
cn.Open ConnectStr

PerformanceData = "xml connect : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

rs.Open ????, cn, adOpenForwardOnly, adLockReadOnly, adCmdTable

PerformanceData = PerformanceData + "xml open rs : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

Set oStream = New ADODB.Stream
rs.Save oStream, adPersistXML
XmlData = oStream.ReadText
oStream.Close
Set oStream = Nothing

PerformanceData = PerformanceData + "xml rs to xml : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
XmlGetData = 0
PerformanceData = PerformanceData + "Xml end : " + CStr(GetTickCount - ddd)
Exit Function
errhandle:
XmlGetData = -1
End Function

Public Function StrGetData(ByRef StrData As String, ByRef PerformanceData As String) As Long
On Error GoTo errhandle
Dim ddd As Long
Dim ConnectStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

ddd = GetTickCount
ConnectStr = "Provider=SQLOLEDB.1;username=ying wenjing;password=ywj;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=WFMSTry;Data Source=m18dbhp"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
cn.Open ConnectStr

PerformanceData = "getStr connect: " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

rs.Open "workiteminstance", cn, adOpenStatic, adLockReadOnly, adCmdTable

PerformanceData = PerformanceData + "getStr data to rs : " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

StrData = rs.GetString

PerformanceData = PerformanceData + "getStr rs to string: " + CStr(GetTickCount - ddd) + Chr(13)
ddd = GetTickCount

rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
StrGetData = 0
PerformanceData = PerformanceData + "getStr time: " + CStr(GetTickCount - ddd)
Exit Function
errhandle:
StrGetData = -1
End Function

测试工程
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim rs As ADODB.Recordset
Dim stm As Stream
Dim str As String
Dim xmlreturn As String
Private Sub Command1_Click()
If rs.State = adStateOpen Then Debug.Print rs.GetString
End Sub

Private Sub Command2_Click()
Debug.Print xmlreturn
End Sub

Private Sub Command3_Click()
Debug.Print str
End Sub

Private Sub Command4_Click()
Dim aa As Object
Dim returnstr As String


Dim cc As Long
'Set rs = New Recordset

Set aa = CreateObject("ProDataTransfertest.CDataTransfertest")
cc = GetTickCount
Debug.Print aa.MarGetData(rs, returnstr)
Debug.Print "Marshal time " + CStr(GetTickCount - cc)
Debug.Print "performance :" + Chr(13) + returnstr
cc = GetTickCount
Debug.Print aa.XmlGetData(xmlreturn, returnstr)
Debug.Print "Xml time " + CStr(GetTickCount - cc)
Debug.Print "performance :" + Chr(13) + returnstr

cc = GetTickCount
Debug.Print aa.StrGetData(str, returnstr)
Debug.Print "getstring time " + CStr(GetTickCount - cc)
Debug.Print "performance :" + Chr(13) + returnstr

Set aa = Nothing


End Sub
xhfjy 2002-02-27
  • 打赏
  • 举报
回复
呵,不错
lance09 2002-02-27
  • 打赏
  • 举报
回复
收藏
VB_support 2002-02-27
  • 打赏
  • 举报
回复
经典,保存
Meditate 2002-02-27
  • 打赏
  • 举报
回复
ADO.Recordset本身支持在各层之间复制,但是最好使用本地光标,我曾经做过,没有问题!
而且,也可以把它转换为xml进行数据传输!
halfdream 2002-02-27
  • 打赏
  • 举报
回复
将数据集打包传递应该在三层开发中应该是很常见的。
尽管这是VB区,因为COM/DCOM是与具体语言无关的,
我还是得提一下在DELPHI,中。 使用Midas.dll把
数据集的数据打包传往客户端,是平常得不能再平常的.
我曾在这方面做过一些尝试,用VB可以轻易取得DELPHI做的
应用服务器的数据集包,只是看起来似乎意义不大。
在MS的工具中,也应该对数据集打包提供了足够的支持。
另外,传递数据集用XML也应该是可行的。





cnzjf99 2002-02-27
  • 打赏
  • 举报
回复
对象的传递无非值与引用或者通过其他中间介质,如文件等,根据你的情况你那Recordset不是很大,游标可设在Client,类型设为Static
0aaron 2002-02-27
  • 打赏
  • 举报
回复
在一台机器我就试过,在两台就没试过了
xiaomao_336 2002-02-27
  • 打赏
  • 举报
回复
Test
badbird 2002-02-27
  • 打赏
  • 举报
回复
to : wjying(葡萄)

参考ms的RDS实现。

我曾经做过一个项目,利用rds和微软的数据绑定实现在浏览器中的数据浏览,recordSet完全是在客户端的,并且不用保持同中间层的连接。

希望对我的回答加分
zljzyj 2002-02-27
  • 打赏
  • 举报
回复
COM是不支持远程调用,但
COM+还不可以通过防火墙??????????
缺省情况下是不行:
(摘自:http://support.microsoft.com/default.aspx?scid=kb;EN-US;q248809)

For DCOM to work, the client must be able to reach the server by its actual IP
address. If you use firewalls that translate network addresses, the client
cannot use the actual IP address to reach the server. COM inserts the IP
address of the server computer into the interface marshaling packets that
are returned to the client. Instead of using the translated IP/header,
Remote Procedure Call (RPC, or DCOM) uses the actual IP address to reach
the server. Because the firewall prevents the client from directly accessing
the server, the client Does Not Work over Network Address Translation-Based Firewall .
但经过配置后就可以:
http://www.microsoft.com/com/wpaper/dcomfw.asp
Fly2000 2002-02-27
  • 打赏
  • 举报
回复
用soap.
lanying 2002-02-27
  • 打赏
  • 举报
回复
com中:
Public Function Foo() as ADODB.Recordset
Dim rs As New ADODB.Recordset
...

set Foo=rs
End Function
加载更多回复(71)

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧