Am using the code below to generate my report and it works alright. but the report keeps asking for username and password. how do i avoid this
private void btnshow_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.ConnectionString = "Data Source=USER-PC;Initial Catalog=MUCGPROJECT;User ID=sa;Password=mike";
SqlCommand cmd = new SqlCommand(string.Format("SELECT * FROM tblCollectorsRegistration WHERE
Collectorid='{0}'", this.txtCollectorid.Text), conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
conn.Close();
DataTable tbl = new DataTable();
conn.Open();
SqlDataAdapter adp = new SqlDataAdapter("SELECT Collectorid, Title, Surname, Firstname,
Middlename, Gender, Dateofbirth, Nationality, Religion, Maritalstatus, Spousename,
Telephone, Postaladdress, Residentialaddress, Hometownaddress from
tblCollectorsRegistration WHERE Collectorid = '" + this.txtCollectorid.Text + "'", conn);
adp.Fill(tbl);
rptCollectorindividual objRpt = new rptCollectorindividual();
objRpt.Database.Tables[0].SetDataSource(tbl);
crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
}
else
{
// Id already present
MessageBox.Show("The Collector ID does not Exist");
return;
}
}