原来有一段代码是连SQL server的,现在我要改成连test.mdb 里的test表。用户名:Admin
,密码为123,请问如何修改://设置数据库连接变量//数据库服务器(local),数据库名staff,用户名sa,密码sa m_Report->Database ->Tables ->Item [1]->SetLogOnInfo("(local)","staff","sa","sa");//设置检索SQL命令m_Report->put_SQLQueryString ((_bstr_t)"select * from person where id<'4' order by id");//不显示重复字段 m_Report->PutEnableSelectDistinctRecords (TRUE); //设置检索条件,采用水晶报表语法,功能同设置检索SQL命令m_Report->PutRecordSelectionFormula ((_bstr_t)"{person.id}='1'");
,密码为123,请问如何修改://设置数据库连接变量//数据库服务器(local),数据库名staff,用户名sa,密码sa m_Report->Database ->Tables ->Item [1]->SetLogOnInfo("(local)","staff","sa","sa");//设置检索SQL命令m_Report->put_SQLQueryString ((_bstr_t)"select * from person where id<'4' order by id");//不显示重复字段 m_Report->PutEnableSelectDistinctRecords (TRUE); //设置检索条件,采用水晶报表语法,功能同设置检索SQL命令m_Report->PutRecordSelectionFormula ((_bstr_t)"{person.id}='1'");
m_Report->Database ->Tables ->Item [1]->SetLogOnInfo("....");//这里设置成为你的mdb数据库目录的绝对路径
......
GOOGLE下就有了
m_Report->Database->Tables->Item[1]->SetLogOnInfo("c:\\temp\\test.mdb");
这一句编译时通过,但运行时报错:
运行时错误,程序非法终止.
Runtime error,abnormal program terminate
这么简单的语句都有错,很郁闷不知大家遇到过这样的问题没有。
'TableLogOnInfo提供属性,以便检索和设置表连接选项。
Dim logOnInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim i As Integer
' 对报表中的每个表依次循环。
For i = 0 To report.Database.Tables.Count - 1
' 设置当前表的连接信息。
logOnInfo.ConnectionInfo.ServerName = "server"
logOnInfo.ConnectionInfo.DatabaseName = "database"
logOnInfo.ConnectionInfo.UserID = "sa"
logOnInfo.ConnectionInfo.Password = "sa"
report.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
Next i End Sub