i am accessing table from my access database in my wpf application. But problem is my column containing ID have blank spaces in the start. Eg. My table contains Estimation ID column which contains different IDs like 141A, 14B, 13521B. but at the start of these IDs there are some blank spaces.( 141A, 14A, 14152B) so when i pass the parameter from the query in my wpf application, it returns empty table. my code is
string query1 = "select * from Estimates where EstimateNo = '141A'";
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(query1, myDataConnection);
da.Fill(dt);
is there any method where i can specify condition at where clause . i.e can contain any number of white spaces at start but should end which this ie code ?
what to do now?
The function you are looking for is LTRIM
string query1 = "select * from Estimates where LTRIM(EstimateNo) = '141A'";
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(query1, myDataConnection);
da.Fill(dt);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With