Derek Hart
2009-07-25 02:53:04 UTC
I am converting an Access application where I would pass an adodb recordset
over to Microsoft Word. Now in dotnet I am creating the recordset, and
passing it to Word, but it only stay in memory for a short time. As soon as
I used the recordset, it is gone. It is like Access just passed the
recordsets by value, but in dotnet it holds onto them and closes them. Here
is some code I use to create the recordset, and then I pass 4 recordsets as
parameters into MS Word. Better way to do this so the recordsets stay in
memory. And I specifically do not close them in the dotnet routine:
cn = New ADODB.Connection
cn.Open("Provider=SQLOLEDB.1;Data Source=delllaptop2;Initial
Catalog=igen;integrated security=SSPI")
rsFormName = New ADODB.Recordset
rsDataName = New ADODB.Recordset
rsDataItemDef = New ADODB.Recordset
rsDataItemDefDataPreparation = New ADODB.Recordset
sql = "exec dbo.spFormNameIDWithFieldsChooseSel " & GroupID
rsFormName.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataPreparationDataNameSel " & GroupID & ",'"
& RepQuote(FormNameID) & "'"
rsDataName.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataItemDefFromGroupIDSel " & GroupID
rsDataItemDef.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataPreparationListFieldSel " & GroupID & ",'"
& RepQuote(FormNameID) & "'"
rsDataItemDefDataPreparation.Open(sql, cn,
ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
I run a specific macro in Word:
objWord.Run(macroname:="FillMergeFields", varg1:=rsFormName,
varg2:=rsDataName, varg3:=rsDataItemDef,
varg4:=rsDataItemDefDataPreparation)
Worked great loading this data into Word from Access, but dotnet wants to
hold onto and control the arguments. Any ideas would be appreciated as to
what the best way to do this might be...
over to Microsoft Word. Now in dotnet I am creating the recordset, and
passing it to Word, but it only stay in memory for a short time. As soon as
I used the recordset, it is gone. It is like Access just passed the
recordsets by value, but in dotnet it holds onto them and closes them. Here
is some code I use to create the recordset, and then I pass 4 recordsets as
parameters into MS Word. Better way to do this so the recordsets stay in
memory. And I specifically do not close them in the dotnet routine:
cn = New ADODB.Connection
cn.Open("Provider=SQLOLEDB.1;Data Source=delllaptop2;Initial
Catalog=igen;integrated security=SSPI")
rsFormName = New ADODB.Recordset
rsDataName = New ADODB.Recordset
rsDataItemDef = New ADODB.Recordset
rsDataItemDefDataPreparation = New ADODB.Recordset
sql = "exec dbo.spFormNameIDWithFieldsChooseSel " & GroupID
rsFormName.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataPreparationDataNameSel " & GroupID & ",'"
& RepQuote(FormNameID) & "'"
rsDataName.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataItemDefFromGroupIDSel " & GroupID
rsDataItemDef.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)
sql = "exec dbo.spDataPreparationListFieldSel " & GroupID & ",'"
& RepQuote(FormNameID) & "'"
rsDataItemDefDataPreparation.Open(sql, cn,
ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
I run a specific macro in Word:
objWord.Run(macroname:="FillMergeFields", varg1:=rsFormName,
varg2:=rsDataName, varg3:=rsDataItemDef,
varg4:=rsDataItemDefDataPreparation)
Worked great loading this data into Word from Access, but dotnet wants to
hold onto and control the arguments. Any ideas would be appreciated as to
what the best way to do this might be...