VB这个程序谁能告诉我是从哪里连接数据库的 谢谢了

PrivateSub日报_Click()OnErrorResumeNextSelectDate=Format(DTPicker1.Value,"yyyy-mm-dd")I... Private Sub 日报_Click()
On Error Resume Next
SelectDate = Format(DTPicker1.Value, "yyyy-mm-dd")

If Dir("c:\报表", vbDirectory) = "" Then
MkDir "c:\报表"
MkDir "c:\报表\日报"
MkDir "c:\报表\月报"
MkDir "c:\报表\年报"
End If
openFile = "c:\报表\日报\"
End Sub

Private Sub 日报查看_Click()
On Error Resume Next
消息.Caption = "正在显示日报请稍候..."
Call 日报_Click
Dim StrDir As String
StrDir = "c:\报表\日报\"

Set xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlApp.Visible = False
On Error GoTo ErrorHandle
Set xlBook = xlApp.Workbooks.Open(StrDir & SelectDate & ".xls", , False)
Set xlSheet = xlBook.Worksheets(1)
xlApp.Visible = True
xlApp.DisplayAlerts = False
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
消息.Caption = "日报显示完毕,可以查看!"
Exit Sub
ErrorHandle:
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
消息.Caption = "所选日期报表不存在!请先生成报表!"
MsgBox "所选日期报表不存在!请先生成报表!"
End Sub

'——————————————————————日报生成并显示——————————————————————
Private Sub 日报生成_Click()
On Error Resume Next
消息.Caption = "正在生成日报,时间较长请稍候..."
Call 日报_Click

Dim StrDir As String
StrDir = App.Path & "\报表\模板\"

Dim saveFile As String
saveFile = "c:\报表\日报\"

Dim i As Long

Dim sPro As String
Dim sSer As String
Dim sCon As String
Dim ssql As String

Dim m, n, s
sPro = "Provider=WinCCOLEDBProvider.1;"
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
startTime = SelectDate & " 08:00:00"
beginTime = DateAdd("h", -7, startTime)
endTime = DateAdd("s", -1, DateAdd("h", 24, beginTime))

Set cnADO = CreateObject("ADODB.Connection")
cnADO.ConnectionString = sCon
cnADO.CursorLocation = 3
cnADO.Open

Set rsADO = CreateObject("ADODB.Recordset")
Set cmADO = CreateObject("ADODB.Command")
cmADO.CommandType = 1
Set cmADO.ActiveConnection = cnADO

Set xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open(StrDir & "Day.xls")

'—*—*—*—*—*—*—*—*—*—*—*—*—开始产生Sheet—*—*—*—*—*—*—*—*—*—*—*—*—
Call CuGeShan
'—*—*—*—*—*—*—*—*—*—*—*—*—结束产生Sheet—*—*—*—*—*—*—*—*—*—*—*—*—
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlBook.SaveAs FileName:=saveFile & SelectDate & ".xls"
'xlBook.Close (True)
'xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
cnADO.Close
Set cnADO = Nothing
Set rsADO = Nothing
消息.Caption = "日报生成并显示完毕,请查看!"
End Sub
Dim m, n, s
sPro = "Provider=WinCCOLEDBProvider.1;"
sSer = "Data Source=.\WinCC"
sCon = sPro + sDsn + sSer
startTime = SelectDate & " 08:00:00"
beginTime = DateAdd("h", -7, startTime)
endTime = DateAdd("s", -1, DateAdd("h", 24, beginTime))

这个时间是什么意思
展开
 我来答
计名pS
2010-01-20
知道答主
回答量:0
采纳率:0%
帮助的人:0
展开全部
Set cnADO = CreateObject("ADODB.Connection")
cnADO.ConnectionString = sCon
cnADO.CursorLocation = 3
cnADO.Open

Set rsADO = CreateObject("ADODB.Recordset")
Set cmADO = CreateObject("ADODB.Command")
cmADO.CommandType = 1
Set cmADO.ActiveConnection = cnADO

==========================

beginTime = DateAdd("h", -7, startTime)
'把startTime小时数(h)减7
'其它同理,参考DateAdd()函数
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
?>

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式