how i can make sure the user prints only his selected information not other user's information both users use same table or same dataset with cyrstal report
pls help
i am using c# application , VS2019 with crystal report to be used by doctors to print prescriptions at the same time
thanks
OB


Adarsh NigamRank #950 · 2.1K reputationPosted Jul 4, 2024, 1:51 PM EDT
To ensure that each doctor prints only their selected information and not data from other users in a C# application using Crystal Reports, you can implement the following steps:
User Authentication and Authorization:
Parameterized Reports:
Data Filtering in the Query:
Implementation Example
User Login:
Filtering Data:
SELECT * FROM Prescriptions WHERE DoctorID = @DoctorIDPassing Parameters to Crystal Report:
Code Example
// Assuming you have a method to get the logged-in doctor's ID int loggedInDoctorId = GetLoggedInDoctorId(); // Fetch data filtered by DoctorID var filteredData = GetDataForDoctor(loggedInDoctorId); // Create a new Crystal Report instance ReportDocument reportDocument = new ReportDocument(); reportDocument.Load("PathToYourReportFile.rpt"); // Set the data source for the report reportDocument.SetDataSource(filteredData); // Optionally, pass parameters if needed reportDocument.SetParameterValue("DoctorID", loggedInDoctorId); // Display or print the report crystalReportViewer.ReportSource = reportDocument;Explanation
This approach ensures that each doctor can only print their own prescriptions, maintaining data privacy and integrity.