数据查询提取:
Code
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Dim item As NotesItem
Set db=session.currentdatabase
Set doc=New notesdocument(db)
doc.form = "test"
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库名" 'uid=xxx;pwd=xxx
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT name,collage from PersonData"
rs.open SQL,con,1,3
rs.MoveFirst
Do While Not rs.eof
field=rs.Fields("name").name
value=rs.Fields("collage").value
Msgbox field
Msgbox value
Set item = doc.AppendItemValue(field,value)
rs.MoveNext
Call doc.save(True,True)
Set db = session.CurrentDataBase
Set doc = New NotesDocument(db)
doc.form = "test"
Loop
rs.close
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Dim item As NotesItem
Set db=session.currentdatabase
Set doc=New notesdocument(db)
doc.form = "test"
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库名" 'uid=xxx;pwd=xxx
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT name,collage from PersonData"
rs.open SQL,con,1,3
rs.MoveFirst
Do While Not rs.eof
field=rs.Fields("name").name
value=rs.Fields("collage").value
Msgbox field
Msgbox value
Set item = doc.AppendItemValue(field,value)
rs.MoveNext
Call doc.save(True,True)
Set db = session.CurrentDataBase
Set doc = New NotesDocument(db)
doc.form = "test"
Loop
rs.close
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub
数据删除:
Code
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Set db=session.currentdatabase
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库"
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT * from PersonData"
rs.open SQL,con,1,3 '''''''''''''''''''
rs.MoveFirst
rs.Delete
rs.Update ''''''''''''''''''
rs.close
con.close
Set rs=Nothing
Set con= Nothing
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Set db=session.currentdatabase
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库"
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT * from PersonData"
rs.open SQL,con,1,3 '''''''''''''''''''
rs.MoveFirst
rs.Delete
rs.Update ''''''''''''''''''
rs.close
con.close
Set rs=Nothing
Set con= Nothing
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub
数据添加:
Code
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Dim item As NotesItem
Set db=session.currentdatabase
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库名"
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT * from PersonData"
rs.open "PersonData",con,1,3,2 '''''''''''''''''''
rs.AddNew '''''''''''''''''''
rs.Fields("name").value="罗宾逊"
rs.Fields("sex").value="男"
rs("age").value="41"
rs("collage").value="麻省理工"
rs("company").value="SUN"
rs.Update '''''''''''''''''''
rs.close
con.close
Set rs=Nothing
Set con= Nothing
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub
Sub Initialize
On Error Goto errors
Dim session As New Notessession
Dim db As Notesdatabase
Dim doc As notesdocument
Dim item As NotesItem
Set db=session.currentdatabase
Dim con As Variant
Set con = CreateObject("ADODB.Connection")
ConAdmin = "driver={SQL Server};server=数据源ip;database=数据库名"
con.open ConAdmin
Set rs=createobject("adodb.recordset")
SQL="SELECT * from PersonData"
rs.open "PersonData",con,1,3,2 '''''''''''''''''''
rs.AddNew '''''''''''''''''''
rs.Fields("name").value="罗宾逊"
rs.Fields("sex").value="男"
rs("age").value="41"
rs("collage").value="麻省理工"
rs("company").value="SUN"
rs.Update '''''''''''''''''''
rs.close
con.close
Set rs=Nothing
Set con= Nothing
Exit Sub
errors:
Msgbox Str(Err)+" At "+Str(Erl)+". "+Error$
End Sub