简体   繁体   中英

Crystal reports failed to open connection

hey there everyone. so, have ac# windows form that uses crystal reports and a sql express backend and one crystal report that pulls from a remote sql server 08. when trying to pull from the local database, i get a 'failed to open connection' but the report loads fine from the remote connection.

everything works great on the development machine, it's when testing on a virtual machine it fails. the DB on the virtual was created using a (current)backup of the develoment DB. here's the code for the connection...

private void frm_cr_Visit_Load(object sender, EventArgs e)
    {
        this.Text = "Visit Report - Version:" + Application.ProductVersion;
        Cursor.Current = Cursors.WaitCursor;
        ReportDocument cryRpt = new ReportDocument();
        cryRpt.Load(@"C:\Data\MRE\crVisitBySubVisitID.rpt");
        cryRpt.SetDatabaseLogon("login", "password", @"localserver\sqlexpress", "DBname");
        cryRpt.SetParameterValue("@VisitID", intVisitID);
        cryRpt.SetParameterValue("@FullName", GlobalVariables.GlobalFullName);
        crv.ReportSource = cryRpt;
        crv.Refresh();
        Cursor.Current = Cursors.Default;
    }

all other DB functions within the program work. what causes the problem, and how do i fix it?

thanks!
dave k

如果所有其他功能都起作用且数据库详细信息相同,请检查用户的权限,因为这是连接问题的常见原因(假设身份验证明显返回了该错误),还检查了URL(因为没有有关服务器名称的更多信息)假定显然,如果设置了HOSTS文件或服务器名称,以便“ localserver”起作用,则“ localserver”可能应为“ localhost”。

found my problem, it had to do with the sql server being set up for only windows authentication, and not that and sql login authentication.

doh!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM