Using BO.Seek with strings and single quotes


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan, Edhy, many thanks for your replies.

Since posting , I have discovered that doing a seek on a BO.Seek  is too slow (With thousands of transactions) so I have gone back to Seeking the Database itself, and here I can use parameters anyway, so not a problem

Just one query though, If I do as seek with the replaced two single quotes, does it seek for the Single Quote or seek for two single quotes

In an example, I used a variable to hold the string (with the single quote replaced with two single quotes) , and if it was not found, it inserts it, but it inserted two single quotes !!
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Yep, looks good. Wink
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ger, Ivan,

Since no parameter can be used in the bo.Seek() I am a big fan of using the String.Format to get my expression clearer, so I would use something like this:
Me.MyBO.Seek(String.Format("MyName='{0}'"Me.MyBO.MyName.Replace("'""''")))


Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Ger.

Try:

MyBo.seek("Comp_name = " + "'"  + myName.Replace("'", "''")  + "'")

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a variable called myName and its value is -->  Paddy O'Sullivan

I have a MyBo.seek("Comp_name = " + "'"  + myName   + "'") and its erroring out, I think  because of the embedded single quote in the name before Sullivan

(If I was doing this in SQL (as opposed to a BO) I'd use a Parameter so single quotes would not be a problem)

I know I cam probably get over this by replacing single quotes with adifferent character but I wont get a proper result then.

Is there any way of using e Parameter structure when I do BO.Seek ?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search