|
|
发表于 2003/11/7 15:11:49
|
显示全部楼层
修改网友后的程序。^_^。大家共享讨论!
接受sql数据导成notes文档:
Sub Click(Source As Button)
Dim con As New odbcconnection
Dim qry As New odbcquery
Dim res As New odbcresultset
Dim temp As Variant
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Set db=session.currentdatabase
If con.connectto("TestForLouts") Then
Set qry.connection=con
qry.sql= "select * from TABLE1"
Set res.query=qry
res.execute
If res.isresultsetavailable=True Then
Set doc=db.createdocument
doc.form="Main"
res.firstrow
doc.Name=res.getvalue("Name")
doc.Birth=res.getvalue("Birth")
doc.Age=res.getvalue("Age")
doc.Word=res.getvalue("Word")
Call doc.save(True,False)
Do
Set doc=db.createdocument
doc.form="Main"
res.nextrow
doc.Name=res.getvalue("Name")
doc.Birth=res.getvalue("Birth")
doc.Age=res.getvalue("Age")
doc.Word=res.getvalue("Word")
Call doc.save(True,False)
Loop Until res.isendofdata
End If
Else
Messagebox("Could not connect to database server")
End If
End Sub
用表单上填写数据,传给sql:
Sub click (source As button)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim view As notesview
Dim con As New odbcconnection
Dim qry As New odbcquery
Dim result As New odbcresultset
Set uidoc=w.currentdocument
Set doc=uidoc.document
If con.connectto("TestForLouts") Then
Set qry.connection=con
qry.sql="select * from Table1"
Set result.query=qry
qry.sql= "insert into TABLE1(Name,Birth,Age,Word) values('" + doc.Name(0) + "','" + Cstr(doc.Birth(0)) + "','" +Cstr(doc.Age(0)) + "','" +doc.Word(0) + "')"
Call result.execute()
Call result.addrow()
Call result.updaterow
Call con.disconnect()
Messagebox("save the date")
Else
Messagebox("do not save")
End If
result.close(db_close)
con.disconnect
End Sub
 |
|