lotus利用ODBC类操作SQL数据库代码--已通过

以下是俺学习参考别人有关NOTES与关系数据库互相操作的文档后更新的LOTUSSCRIPT程序代码 Set con=New ODBCConnection Set qry=New ODBCQuery Set rs=New ODBCResultSet Set qry.Connection = con Set rs.Query=qry Set ws=New notesuiworkspace Set uidoc=ws.currentdocument Dim s As New NotesSession Dim db As NotesDatabase Dim tempdoc As NotesDocument Dim StudentView As NotesView Dim j As Integer Set db=s.CurrentDatabase Set StudentView = db.GetView("($studentid)") Call con.ConnectTo("arice","","") qry.SQL="Select * From people" rs.execute rs.LastRow rs.CurrentRow = currentrow If Cstr(uidoc.fieldgettext("Saveoptions"))="0" Then '如果是新建表单 Set tempdoc=StudentView.GetDocumentByKey(Trim(uidoc.fieldgettext("Student_ID")),True)'判断是否在视图存在此学生id的表单 If Not tempdoc Is Nothing Then'如果存在 Messagebox "系统已经存在,请不要重复录入",,"警告" continue=False Exit Sub Else j = 0 For i = 1 To rs.NumRows rs.CurrentRow = i If Cstr(rs.GetValue("Cname")) = Cstr(uidoc.FieldGetText("Student_ID")) Then j = j + 1 End If Next '==============更新操作================================================== If j > 0 Then Call rs.SetValue("Student_id",Cstr(uidoc.FieldGetText("Student_ID"))) 'Messagebox "执行第一条语句" Call rs.SetValue("CName", Cstr(uidoc.fieldgettext("CName"))) 'Messagebox "执行第二条语句" Call rs.SetValue("EName", Cstr(uidoc.fieldgettext("EName"))) Call rs.SetValue("Address",Cstr(uidoc.fieldgettext("Address"))) Call rs.SetValue("Tel",Cstr(uidoc.fieldgettext("Tel"))) 'Messagebox "执行第五条语句" If rs.UpdateRow Then Messagebox "提交SQL数据库成功" 'Call uidoc.fieldsettext("Saveoptions","1") Call uidoc.Save(False,False) Else Messagebox "保存SQL数据库失败" Exit Sub End If Else Messagebox "是新增的文档,待定新增代码处理!" '====================新增保存代码========================= rs.AddRow Call rs.SetValue("Student_id",Cstr(uidoc.FieldGetText("Student_ID"))) Call rs.SetValue("CName", Cstr(uidoc.fieldgettext("CName"))) Call rs.SetValue("EName", Cstr(uidoc.fieldgettext("EName"))) Call rs.SetValue("Address",Cstr(uidoc.fieldgettext("Address"))) Call rs.SetValue("Tel",Cstr(uidoc.fieldgettext("Tel"))) If rs.UpdateRow Then Call uidoc.fieldsettext("Saveoptions","1") Call uidoc.Save(True,False) Messagebox "提交SQL数据库成功" Else Messagebox "保存SQL数据库失败" Exit Sub End If End If End If 'Messagebox "执行update条语句" Else Call rs.SetValue("Student_id",Cstr(uidoc.FieldGetText("Student_ID"))) 'Messagebox "执行第一条语句" Call rs.SetValue("CName", Cstr(uidoc.fieldgettext("CName"))) 'Messagebox "执行第二条语句" Call rs.SetValue("EName", Cstr(uidoc.fieldgettext("EName"))) Call rs.SetValue("Address",Cstr(uidoc.fieldgettext("Address"))) Call rs.SetValue("Tel",Cstr(uidoc.fieldgettext("Tel"))) 'Messagebox "执行第五条语句" If rs.UpdateRow Then Messagebox "提交SQL数据库成功" 'Call uidoc.fieldsettext("Saveoptions","1") Call uidoc.Save(True,False) Else Messagebox "保存SQL数据库失败" Exit Sub End If End If rs.Close(DB_CLOSE) con.Disconnect

















BY ARICE.LEE
2010-3-3
Set con=New ODBCConnection
Set qry=New ODBCQuery
Set rs=New ODBCResultSet
Set qry.Connection = con
Set rs.Query=qry
Set ws=New notesuiworkspace
Set uidoc=ws.currentdocument
Dim s As New NotesSession
Dim db As NotesDatabase
Dim tempdoc As NotesDocument
Dim StudentView As NotesView
Dim j As Integer
Set db=s.CurrentDatabase
Set StudentView = db.GetView("($studentid)")
Call con.ConnectTo("arice","","")
qry.SQL="Select * From people"
rs.execute
rs.LastRow
rs.CurrentRow = currentrow
If Cstr(uidoc.fieldgettext("Saveoptions"))="0" Then '如果是新建表单
Set tempdoc=StudentView.GetDocumentByKey(Trim(uidoc.fieldgettext("Student_ID")),True)'判断是否在视图存在此学生id的表单
If Not tempdoc Is Nothing Then'如果存在
Messagebox "系统已经存在,请不要重复录入",,"警告"

- 纳兰千嬅2014-02-28不知道是不是兼容性问题,打不开
- 轻风映月2014-01-07方法很好,可以用
- 粉丝: 0
- 资源: 2

我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
