用lotus如何连sql server?

dos7 2002-04-11 08:00:39
加精
能告诉我用odbc的具体步骤吗,还有之后用到的lotus语言,谢谢。
...全文
92 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
justle_domino 2002-04-19
  • 打赏
  • 举报
回复
Sub Click(Source As Button)
Dim ws as new notesuiworkspace
dim ss as new notesSession
dim db as notesdatabase
dim doc as notesdocument

set odbcCon = New odbcconnection
set db = ss.currentdatabase
set doc = db.Createdocument

doc.availablesources=odbccon.listdatasources
Call ws.DialogBox("odbc",true,true,false,false,false,false,"选择 数据源",doc)
sourceName$=doc.datasource(0)
if sourceName$= "" then
messagebox "您没有指定数据源名称"
exit sub
end if

if not odbccon.connectto(sourceName$) then
if messagebox("连接失败,是否需要通过口令再登录一次?",4,"") then
username$=Inputbox$("输入用户名:")
passwd$=Inputbox$("输入口令:")
if not odbccon.connectto(sourceName$,username$,passwd$) then
messagebox "连接失败"
exit sub
end if
end if
exit sub
end if
messagebox "已成功连接到数据源"
end sub





artdewey 2002-04-19
  • 打赏
  • 举报
回复
agree above
mh_fan 2002-04-17
  • 打赏
  • 举报
回复
建一个系统dsn
原代码,大r5与sql server2000上测试通过
uselsx "*Lsxodbc"

Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet

Set qry.Connection = con
Set result.Query = qry
Set uidoc=ws.currentdocument
Set doc=uidoc.document
If (doc.gh(0)="") Or (doc.xm(0)="") Then
Messagebox"工号与姓名是必填内容!"
Exit Sub
End If
If con.connectto("test","fan","fan") Then
'检察是修改还是录入
If doc.option(0)="修改" Then
qry.sql="delete fan where 工号='"&doc.gh(0)&"'"
result.execute
qry.sql="insert into fan values ('"&doc.gh(0)&"','"&doc.bmh(0)&"','"&doc.xm(0)&"','"&doc.gwgz(0)&"','"&doc.jlgz(0)&"','"&doc.zhbt(0)&"','"&doc.qtbt(0)&"','"&doc.bf(0)&"','"&doc.yfgz(0)&"','"&doc.gjj(0)&"','"&doc.ylbx(0)&"','"&doc.sybx(0)&"','"&doc.ff(0)&"','"&doc.grsds(0)&"','"&doc.qt(0)&"','"&doc.xl(0)&"','"&doc.sfgz(0)&"','"&doc.yf(0)&"','"&doc.zhmc(0)&"')"
result.execute
Messagebox"修改完毕!"
Exit Sub
End If
'检察是否有重复
qry.sql="select count(*) as aa from fan where 工号='"&doc.gh(0)&"'"
result.execute
If Cint(result.getvalue("aa"))>0 Then
Messagebox"这个工号有人使用,请重新写!"
Exit Sub
End If
qry.sql="insert into fan values ('"&doc.gh(0)&"','"&doc.bmh(0)&"','"&doc.xm(0)&"','"&doc.gwgz(0)&"','"&doc.jlgz(0)&"','"&doc.zhbt(0)&"','"&doc.qtbt(0)&"','"&doc.bf(0)&"','"&doc.yfgz(0)&"','"&doc.gjj(0)&"','"&doc.ylbx(0)&"','"&doc.sybx(0)&"','"&doc.ff(0)&"','"&doc.grsds(0)&"','"&doc.qt(0)&"','"&doc.xl(0)&"','"&doc.sfgz(0)&"','"&doc.yf(0)&"','"&doc.zhmc(0)&"')"
result.execute
con.disconnect
End If
Messagebox"保存完毕"
Call uidoc.close()
End Sub

希望对你有帮助。
fokker 2002-04-15
  • 打赏
  • 举报
回复
Uselsx "*LSXODBC"
Sub Initialize
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim msg As String
Set qry.Connection = con
Set result.Query = qry
con.ConnectTo("ATDB")
qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
result.Execute
result.LastRow ' Fetch all data into memory at start
soughtrow = Inputbox _
("Which row do you want to change?", "Which row?")
If soughtrow = "" Then
Messagebox "No value entered for row",, "Bad row"
Exit Sub
End If
If soughtrow < 1 Or soughtrow > result.NumRows Then
Messagebox "Row out of range",, "Bad row"
Exit Sub
End If
result.CurrentRow = soughtrow
For i = 1 To result.NumColumns
msg = msg & " " & result.GetValue(i)
Next
soughtcolumn = Inputbox(msg, "Which column?")
If soughtcolumn = "" Then
Messagebox "No value entered for column",, _
"Bad column"
Exit Sub
End If
If soughtcolumn = "" Or soughtcolumn < 1 _
Or soughtcolumn > result.NumColumns Then
Messagebox "Column out of range",, "Bad column"
Exit Sub
End If
newValue = Inputbox$("Enter new value", "SetValue", _
result.GetValue(Cint(soughtcolumn)))
If newValue = "" Then
Messagebox "No value entered"
Exit Sub
End If
Call result.SetValue(Cint(soughtcolumn), newValue)
result.UpdateRow
result.Close(DB_CLOSE)
con.Disconnect
End Sub
huzais 2002-04-15
  • 打赏
  • 举报
回复
我连上了,我只会从里面读出数据来,从表单上把数据写到数据库里面就不会!

请大虾指点!
fokker 2002-04-12
  • 打赏
  • 举报
回复
那可能是你的odbc里面的dsn设置有问题,你把dsn设置完成以后,点击测试数据源,显示“测试成功”了吗?
dos7 2002-04-12
  • 打赏
  • 举报
回复
谢谢,对编程我已有所了解了,但就是odbc连不上,能把具体的步骤告诉我吗。
cooner 2002-04-12
  • 打赏
  • 举报
回复
创建好DSN后,然后利用LOTUS NOTES中的类列表中的最后三个类就可以了
fokker 2002-04-12
  • 打赏
  • 举报
回复
连接到odbc首先的得建一个odbc数据源,剩下的就是编程工作了。
下面是一个连接odbc的例子
Uselsx "*LSXODBC"
'这句是必需的,否则无法ocbc的方法
Sub Initialize
Dim con As New ODBCConnection
Dim dsn As String
Dim msg As String
dsn = Inputbox("ODBC data source name", "DSN")
REM If Not con.ConnectTo(dsn) Then
con.ConnectTo(dsn)
If Not con.IsConnected Then
Messagebox "Could not connect to " & dsn,, _
"Error"
Exit Sub
End If
tables = con.ListTables(dsn)
msg = dsn & " contains the following _
tables:" & Chr(10)
For n% = Lbound(tables) To Ubound(tables)
msg = msg & Chr(10) & tables(n%)
Next
Messagebox msg,, "Tables for " & dsn
con.Disconnect
End Sub
开发思路: 使用ADO通过ODBC链接进行Louts数据读取,在建立一个与SQL server数据库相连的ADO,将读取数据写入SQL server数据库。 安装环境: 首先安装lotus_notes853_win_SC(lotus客户端软件) 然后安装LOTUS_NOTES_SQL_853_W32_CIC6PEN(顺序好像有关系,win8.1安装64位不能正常使用,一定要安装32位的) 数据库连接: 先通过lotus客户端软件连接登陆成功,需要admin.id文件 通过ODBC 数据源(32 位) 添加 Lotus Notes SQL Driver(*.nsf)数据源,选择自己的loust数据库文件.nsf delphi ADO控件通过ODBC Drivers直接连接,本程序中用例名设置为LotusOA,每次连接需要输入lotus密码,其他开发这里就不在介绍可以看源代码 delphi ADO控件连接自己本地的SQL Server数据库,程序下载后自己修改 软件使用: 1、配置:通过config.ini修改LOTUSCONN,即LotusOA设置为自己的建立ODBC的名字,关系数据库修改DBCONN,本例中为SQLServer数据库 2、启动程序,点“数据源链接”,程序连接到lotus数据库和Sql server数据库 设置原始表名:通过lotus设计程序中的试图中可以看到,大部分是fm_Main,设置创建表名用于数据导出的表 3、获取表字段,会读处lotus数据的所有表名,自动目标生成表创建的sql语句,默认字段长度都是254,如需要可以自己修改 4、点“创建表”按钮,如果已创建了不要再点这个按钮 5、点“导出数据”,程序开始自动导出数据 如果目标数据库是其他类型数据库,可自己通过配置文件config.ini中的DBCONN进行修改 lotus导入关系数据库的资源一直很难找,自己的一点拙见,希望对大家有用。
以下是俺学习参考别人有关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

536

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧