水晶报表提示输入用户名密码和数据库名称时出现问题 [英] Problem with the crystal report prompting for username password and database name
问题描述
我只是使用数据集在我的网页上显示水晶报表. Crystal报表已成功在Crystal报表中显示数据.但是问题是,每当我尝试打印时.或缩放水晶报表.提示
您请求的报告需要更多信息.
并请我提供休闲信息
服务器名,数据库名,用户名和密码.
为什么这样做而不是打印或缩放.问题出在哪里
这是代码逻辑.我只是使用数据集显示水晶报表.
i am just showing crystal report on my webpage using dataset. Crystal report is successfully displaying data in a crystal report. but the problem is that whenever i tried to print. or zoom the crystal report. its prompting that
The report you requested requires further information.
and ask me to give the fallowing informatoin
servername ,databasename , username and password.
Why is it doing that instead of printing or zooming . where is the problem
Here is the code logic. i am just displaying crystal report using dataset.
public partial class _Default : System.Web.UI.Page
{
SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
string sid, query;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
sid = Request.QueryString["sid"];
try
{
sqlcon.Open();
//Check whether query string have value or not if not have value then select all record in below query otherwise select particular record with help of where condition
if (sid == "" || sid == null)
{
query = "select * from student";
}
else
{
query = "select * from student where sid='" + sid + "'";
}
sqlcmd = new SqlCommand(query, sqlcon);
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
ReportDocument RptDoc = new ReportDocument();
RptDoc.Load(Server.MapPath("~/CrystalReport.rpt"));
RptDoc.SetDataSource(dt);
CrystalReportViewer1.ReportSource = RptDoc;
CrystalReportViewer1.DataBind();
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
sqlcon.Close();
}
}
}
}
推荐答案
删除此行并尝试
如果(!Page.IsPostBack)
{
Remove this line and try
if (!Page.IsPostBack)
{
提供以下添加LogOn信息以加载Crystal报告
Provide Below addtion LogOn information to load crystal report
Private Sub configureCRYSTALREPORT()
Dim myConnectionInfo As New ConnectionInfo()
myConnectionInfo.DatabaseName = "DatabserName"
myConnectionInfo.UserID = "UID"
myConnectionInfo.Password = "PWD"
setDBLOGONforREPORT(myConnectionInfo)
End Sub
Private Sub setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)
Dim mytableloginfos As New TableLogOnInfos()
mytableloginfos = CrystalReportViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
myTableLogOnInfo.ConnectionInfo = myconnectioninfo
Next
End Sub
这篇关于水晶报表提示输入用户名密码和数据库名称时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!