VS2005 连接数据库问题

Liyp92 2015-11-20 10:41:58
问题如下图片

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.;Initial Catalog=MedicalInsuranceService;Integrated Security=True";
OleDbConnection con = new OleDbConnection(connstr);
OleDbDataAdapter da = new OleDbDataAdapter("SELECT DeviceID,DeviceType,Device,Hospital,DevicePosition From fileHospitalDevice", con);
DataSet ds1 = new DataSet();
da.Fill(ds1, "fileHospitalDevice");

ReportDocument myReport = new ReportDocument();
string reportPath = Server.MapPath("~/app_data/crystalreport1.rpt");
myReport.Load(reportPath);

//CrystalReport1 myReport = new CrystalReport1();

myReport.SetDataSource(ds1);
CrystalReportViewer1.ReportSource = myReport;
}
}
...全文
236 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xdashewan 2015-11-20
  • 打赏
  • 举报
回复
链接字符串的确不对,一般要指定数据库,用户和密码,例如"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\path\xxxxdb.mdb;User Id=admin;Password=123456;"
Liyp92 2015-11-20
  • 打赏
  • 举报
回复
别沉啊= =
Liyp92 2015-11-20
  • 打赏
  • 举报
回复
String connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.;Initial Catalog=MedicalInsuranceService;Integrated Security=True"; 是不是这句有问题呢?大神们
Liyp92 2015-11-20
  • 打赏
  • 举报
回复
OK了。就是连接串问题 String connstr = "Provider=SQLOLEDB;Server=.;Database=MedicalInsuranceService;uid=sa; pwd=sa";
Liyp92 2015-11-20
  • 打赏
  • 举报
回复
引用 3 楼 xdashewan 的回复:
链接字符串的确不对,一般要指定数据库,用户和密码,例如"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\path\xxxxdb.mdb;User Id=admin;Password=123456;"
MedicalInsuranceService就是我的数据库名,我要连接的是SQL,你能说详细点么

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧