用了以下程序,是照以下做的.
http://expert.csdn.net/Expert/topic/2770/2770960.xml?temp=.9375421Private Sub Command2_Click()
Unload DataReport1
........
Adodc1.ConnectionString
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from student "
Adodc1.Refresh
Set DataReport1.DataSource = Adodc1
DataReport1.Sections(3).Controls(1).DataField = "stu_test_id"
DataReport1.Show
End SubDataReport1.Sections(3).Controls(1).DataField = "stu_test_id"
这句话不对,DataReport1.Sections(3).Controls(1)后面没有.DataField
属性,强制执行报错:下标越界.但是我的确在Sections3 里放了Rpttext后来我用数据环境做,创建存储过程:
create procedure sp_report_tests(
   @testid  as  varchar
)
as
  select  t1.stu_test_id,  t1.stu_name, t2.test_desc,
          t2.test_id , t2.test_time
  from student  t1,  testmaster t2   
  where   t2.test_id=t1.test_id  and  t1.test_id=@testid
       
 order  by  t1.stu_test_id两张表里的test_id 都是varchar 5
在查询分析器里执行:
sp_report_tests  '111' 或  sp_report_tests  111
都查不到值,单独执行:
select  t1.stu_test_id,  t1.stu_name, t2.test_desc,
          t2.test_id , t2.test_time
  from student  t1,  testmaster t2   
  where   t2.test_id=t1.test_id  and  t1.test_id='111'       
 order  by  t1.stu_test_id
却可以查到值.
昨晚做到3点,很郁闷