用lotus如何连sql server?

dos7 2002-04-11 08:00:39
加精
能告诉我用odbc的具体步骤吗,还有之后用到的lotus语言,谢谢。
...全文
88 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

536

社区成员

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

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