I am working with .sdf database when i execute the select query i get the following error:
Data conversion failed. [ OLE DB status value (if known) = 2 ]
SELECT
P.PatientID AS [Patient Id],
P.PathentName AS [Patient name],
P.BirthDate AS [Birth Date],
P.Patientsex AS [Patient Sex],
P.Description,
ST.Study Date,
ST.Accessionnumber AS [Acession Number],
ST.ReferDrName AS [Refer Dr.]
FROM
Patients P INNER JOIN Studies ST
ON P.PatientID = ST.PatientID
WHERE
P.PatientID=1234567890
This is my code:
private void pictureBox1_Click(object sender, EventArgs e)
{
SqlCeConnection con = new SqlCeConnection();
con.ConnectionString = "Data Source=Dicom.sdf;Persist Security Info=False;";
string query=null;
query = "SELECT P.PatientId AS [Patient Id], P.Name AS [Patient name], P.BirthDate AS [Birth Date], P.Sex AS [Patient Sex], ST.StudyDescription, ST.StudyDate AS Date, ST.AccessionNumber AS [Acession Number], ST.ReferDrName AS [Refer Dr.] FROM Patients AS P INNER JOIN Studies AS ST ON P.PatientId = ST.PatientId WHERE (P.PatientId = 1234567890)";
SqlCeDataAdapter adp = new SqlCeDataAdapter(query, "Data Source=Dicom.sdf;Persist Security Info=False;");
SqlCeCommandBuilder commandBuilder = new SqlCeCommandBuilder(adp);
DataTable dt = new DataTable();
dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
adp.Fill(dt);
// StudiesbindingSource.DataSource = dt;
dataGridViewStudies.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);// Resize the DataGridView columns to fit the newly loaded content.
// finally bind the data to the grid
dataGridViewStudies.DataSource = dt;
dataGridViewStudies.ReadOnly = true;
dataGridViewStudies.Visible = true;
}