Link to home
Start Free TrialLog in
Avatar of kennysflau
kennysflau

asked on

SQL problem

I generate a SQL dynamically in my code:

strSQLMax = "SELECT MAX(SeqNo) AS MaxSeqNo FROM " + strInfoTable + " WHERE PartsNo LIKE '" + PartsNo + "*';"

the output string of strSQLMax is:
"SELECT MAX(SeqNo) AS MaxSeqNo FROM myTable WHERE PartsNo LIKE 'Parts-No-*';"

And I tried to copy the output string and run it directly on my *.mdb, the SQL works.
However, I cannot run it with "myAdaptor.Fill(myDataSet )"... it just ignore the "Parts-No-*" and could not find any record

Is it a bug of ASP.Net?
Please help!!! It's urgent!!!
SOLUTION
Avatar of t_itanium
t_itanium
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kennysflau
kennysflau

ASKER

I think they are different...

Parts-No-* = Parts-No- + unlimited unknown char
Parts-No-% = Parts-No- + ONE unknown char
try this

idont know if u r using vb or c# anyway...

string temp="";
temp=PartsNo;
temp=temp+"*";


strSQLMax = "SELECT MAX(SeqNo) AS MaxSeqNo FROM " + strInfoTable + " WHERE PartsNo LIKE '" + temp + "';"
It will not wor... as the output string is just the same...

I've tried it anyway... no luck
are you sure it is not finding any record?? or not displaying any record??

if not displaying it may be a problem with viewstate..it has to do with the life cycle of ASP.NET page..

?
I changed it to hard code then it worked

I guess it should not be the viewstate problem
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
kennysflau

can you clarify why you chose my answer as assisting answer and not acceped one.????!!
Because the link provided by carl tawn explains the reason behind the solution. If you see my question, my question is "Is it a bug of ASP.Net?".... I prefer a reason rather than the solution only. But really thank you very much for helping!
ok thanks anyway
:)