例如,我有这个表修改数据表
EmployeeName EmpoyeeID
John Mark 60001
Bent Ting 60002
Don Park 60003
我如何可以显示雇员有在数据表中的前导星号? 示例:* 60001 * 60002 * 60003
public DataTable ListOfEmployee()
{
DataSet ds = null;
SqlDataAdapter adapter;
try
{
using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString))
{
myDatabaseConnection.Open();
using (SqlCommand mySqlCommand = new SqlCommand("Select * Employee", myDatabaseConnection))
{
ds = new DataSet();
adapter = new SqlDataAdapter(mySqlCommand);
adapter.Fill(ds, "Users");
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return ds.Tables[0];
}
我需要显示在水晶报表数据表与员工ID前导星号
public void Employees()
{
ReportDocument rptDoc = new ReportDocument();
Employees ds = new Employees(); // .xsd file name
DataTable dt = new DataTable();
// Just set the name of data table
dt.TableName = "Employees";
dt = ListOfEmployee(); //This function is located below this function
ds.Tables[0].Merge(dt);
string strReportName = "Employees.rpt";
string strPath = Application.StartupPath + "\\Reports\\" + strReportName;
// Your .rpt file path will be below
rptDoc.Load(strPath);
//set dataset to the report viewer.
rptDoc.SetDataSource(ds);
ReportViewer newReportViewer = new ReportViewer();
newReportViewer.setReport(rptDoc);
newReportViewer.Show();
}
有很多方法可以做到这一点,每个方法都是“最好的”方式,具体取决于在查询出数据后你将如何处理数据。你能解释更多(通过编辑原始问题)你查询数据后对数据做什么? –
显示它在哪里?这个问题不是很清楚,为什么你不加星号?例如。 string astData =“*”+ table.GetField(“EmpoyeeID”)。ToString(); –
最好的解决方案是在消耗数据的地方附加星号,而不是在数据表中。 – Khan