未能用指定的连接串 "连接字段" 连接到数据源,连接串中的用户名与密码已隐藏
我是在使用grid++报表功能的时候提示的这个错误
Report.DetailGrid.Recordset.ConnectionString 初始化这个的数据源时,提示这个错误,为什么呢?这个问题貌似在别的电脑上没有
sql server数据库 展开
/// <summary>
/// 打印测试
///
/// 错误注意:Recordset.ConnectionString连接字符串只能使用数组变量的方式写入,否则提示用户名或密码隐藏
/// Report.DetailGrid.Recordset.ConnectionString = @"Provider=SQLOLEDB;Password=" + strconn[3] + ";User ID=" + strconn[2] + ";Initial Catalog=" + strconn[1] + ";Data Source=" + strconn[0] + "";
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnprinttest_Click(object sender, EventArgs e)
{
string strreportpath = "\\意见书.grf";
Getstrconn();
Report.LoadFromFile(Utility.GetReportTemplatePath() + strreportpath);
//dbc.strconn[0]
//Report.DetailGrid.Recordset.ConnectionString = "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=newpos;User ID=sa;Passwrod=123;";
Report.DetailGrid.Recordset.ConnectionString = @"Provider=SQLOLEDB;Password=" + strconn[3] + ";User ID=" +
strconn[2]
+ ";Initial Catalog=" + strconn[1] + ";Data Source=" + strconn[0] + "";
Report.QuerySQL = "select '编号1' as certificatenum,'日期1' as operatedate,'单位1' as operatecompany,'质量意见1' as medicinalsuggest,'工作意见1' as worksuggestion,'建议1' as advice";
Report.DetailGrid.Recordset.QuerySQL = "select id,couponamount,usecouponlowerlimit from coupontemplateactivity";
Report.PrintPreview(true);
}