Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf - select data from MS access database on condition

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?

like image 231
omkar patade Avatar asked May 22 '26 00:05

omkar patade


1 Answers

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);
like image 172
Ralf de Kleine Avatar answered May 23 '26 16:05

Ralf de Kleine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!