AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query GUID type value from database

0 REPLIES 0
Reply
Message 1 of 1
quan_hm
190 Views, 0 Replies

Query GUID type value from database

I was trying to query the SizeRecordId, its type value is GUID (check with SQL lite).

 

I was following this post: https://adndevblog.typepad.com/autocad/2012/12/plant-sdk-sample-of-pnptableselect.html

 

to use PnPTable.Select(). So far every type (string, double) is query successful but not the one with type GUID, in this case is SizeRecordId field.

 

So my code was like this:

 

PipePartSpecification pps = PipePartSpecification.OpenSpecification(spec_file);
                PnPTable fittingsTable = pps.Database.Tables["EngineeringItems"];
string query = "\"SizeRecordId\"=X\'0C3BE84B27D5B447BCFC9EDFB4D9A09D\'";
                PnPRow[] matchDtRows = fittingsTable.Select(query);
PnPRow[] matchDtRows = fittingsTable.Select(query);

 

when running P3D give me this error:

minhquanqttb_1-1680243357606.png

 

But the same query I was using will work in SQL Lite:

minhquanqttb_0-1680243182141.png

You can wonder why the real value is "4BE83B0C-D527-47B4-BCFC-9EDFB4D9A09D" but the query is different, this is the reason: https://stackoverflow.com/questions/7815587/using-guid-in-sqlite-select-where-guid-is-stored-in-the-...

 

For short explain you have to convert it to little endian before doing the query for GUID type value.

 

Really appreciate your guys help.

 

Hoang Minh Quan - Piping design engineer
Autodesk Store for Python Catalog
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report