Webブラウザからの実行 |
前へ 戻る | 次へ |
<%@Language="VBScript"%> <html> <head> <script LANGUAGE="VBScript"> 'Webサーバ上の帳票フォーマットファイルとデータを使って帳票を表示 Sub WfrOpen() Set datObj = Wfrfc1.CreateData("データ1") <% Set db = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") db.Open "Provider=MSDASQL.1;Extended Properties=""DSN=SAMPLE""" rs.Open "Select * from table1", db, 3, 1 'フィールド名を出力 rs.MoveFirst Set fields = rs.Fields Response.Write "datObj.Values = """ For i=0 To rs.Fields.Count-1 Set field = fields.Item(i) Response.Write field.Name & "," Next Response.Write """" & vbCrLf 'データを出力 While Not rs.EOF Response.Write "datObj.Values = """ For i=0 To rs.Fields.Count-1 Set field = fields.Item(i) 'データ中のダブルクォート、改行、スペースを置き換える。 strValue = field.Value If Not InStr(strValue, """") = 0 Then strValue = """" & strValue & """" strValue = Replace(strValue, """", """""") strValue = Replace(strValue, vbCrLf, """ & vbCrLf & """) ElseIf Not InStr(strValue, vbCrLf) = 0 Then strValue = """" & strValue & """" strValue = Replace(strValue, """", """""") strValue = Replace(strValue, vbCrLf, """ & vbCrLf & """) ElseIf Not InStr(strValue, " ") = 0 or Not InStr(strValue, ",") = 0 Then strValue = """""" & strValue & """""" End If Response.Write strValue & "," Next rs.MoveNext Response.Write """" & vbCrLf Wend 'データベースを閉じる rs.Close db.Close %> datObj.Close() Wfrfc1.Open "http://www.tera-soft.com/sample.wfd" End Sub </script> </head> <body onLoad=WfrOpen()> <!--ワンダフルレポートのActiveXコントロールを作成--> <object id="Wfrfc1" classid="CLSID:74F04531-5AF1-11D4-A7EA-0090FE02F720" height="100%" width="100%" > </object> </body> </html> |
<html> <head> <script LANGUAGE="VBScript"> 'Webサーバ上の帳票フォーマットファイルとデータを使って帳票を表示 Sub WfrOpen() Set datObj = Wfrfc1.CreateData("データ1") datObj.Values = "ID,NAME,COMMENT," datObj.Values = "1,""山田 太郎"",""今日は晴れ。" & vbCrLf & "明日は?""," datObj.Values = "2,""鈴木 ○也"",暑い," datObj.Values = "3,""佐藤 健○"",明日は試験だ!!," datObj.Values = "4,""田中 △吾"",""こんにちわ。" & vbCrLf & "さようなら。""," datObj.Close() Wfrfc1.Open "http://www.tera-soft.com/sample.wfd" End Sub </script> </head> <body onLoad=WfrOpen()> <!--ワンダフルレポートのActiveXコントロールを作成--> <object id="Wfrfc1" classid="CLSID:74F04531-5AF1-11D4-A7EA-0090FE02F720" height="100%" width="100%" > </object> </body> </html> |
前へ 戻る | 次へ |