我想要用datareport做一张报表,
1、连接数据库的方式是用ado连接,
2、生成报表前要先让用户选择时间
然后根据时间生成报表,
3、报表的主要内容是统计数据库里记录的累加
那位高手有这样的例子,高分向送!
1、连接数据库的方式是用ado连接,
2、生成报表前要先让用户选择时间
然后根据时间生成报表,
3、报表的主要内容是统计数据库里记录的累加
那位高手有这样的例子,高分向送!
s = "SELECT 职工编号, 姓名,性别,出生日期, 民族,政治面目,文化程度,职务,参加工作日期,职称等级,身份证号,部门,籍贯,'" & ComputerName & "','" & glid & "'"
s = s & " FROM 人事档案 where (人事档案.姓名 is not null)"
If IsDate(rq1) And IsDate(rq2) Then
s = s & " and 人事档案.参加工作日期<= convert(datetime,'" & Format(rq2, "MM-dd-yyyy") & "',102)"
s = s & " AND (人事档案.参加工作日期 >= convert(datetime,'" & Format(rq1, "MM-dd-yyyy") & "',102))"
End If
cn.Execute "INSERT INTO p_人事档案 ([s1], [s2], [s3], [s4], [s5], [s6], [s7],[s8],[s9],[s10],[s11],[s12],[s13],username,glid) " & s rptform!Report1.ReportFileName = ReportPath & "ryflb.rpt"
rptform!Report1.Connect = "DSN=empl;UID=" & loginuid & ";PWD=" & userpwd & ";"
rptform!Report1.SelectionFormula = "{p_人事档案.glid}=" & Val(glid) & " and {p_人事档案.username}='" & ComputerName & "'"
rptform!Report1.Action = 1
上边的语句就是按照时间把人员档案先插入到一个临时表中,然后在把临时表的数据打印出来就可以了。
s = s & " FROM 人事档案 where (人事档案.姓名 is not null)"
这句是什么意思
相当于
s = "SELECT 职工编号, 姓名,性别,出生日期, 民族,政治面目,文化程度,职务,参加工作日期,职称等级,身份证号,部门,籍贯,'" & ComputerName & "','" & glid & "' FROM 人事档案 where (人事档案.姓名 is not null)"
办?是不是不可以用了?我用的是sqlserver数据库
数据环境不影响。
private sub dataenvironment_initialize()
dim strconn as string
strconn="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa" & ";Password=;Initial Catalog= gsgl_sggl;Data Source=" & Server_name"
con.connectionstring=strconn
end sub
这样可以避免机器名被换的时候而还能连接本地的sqlserver数据库吗?
datareport做报表:http://www.yesky.com/20020108/213121.shtml
http://www.cx66.com/cxgzs/program/vb/810.htm
http://www.microsoft.com/china/msdn/technic/develop/vb/0125h.asp
http://www.ahetc.gov.cn/cit/200101/14.doc
http://jinjohn.myrice.com/program/vb/database/data0011.htm