Micro Focus QTP (UFT) Forums
Using GetString to pull information from a DB - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Using GetString to pull information from a DB (/Thread-Using-GetString-to-pull-information-from-a-DB)



Using GetString to pull information from a DB - jcraig26 - 10-30-2012

Okay, I can use the ADO to connect to my databases and I can pull information - I only have read access for testing.

Anyway, when I pull back the specific item I was doing this for, I get extra characters - {}.
It does not appear in the DB with the braces on the outside when I SQL Server manager.

Let's assume the GUID I am looking for is in the correct location and shows: 123-234-456
Here is what I am using in QTP:

Code:
Dim sConnect, sDatabase, sRecord, sGUID, sURL, sSQL
Set sConnect=Createobject("ADODB.Connection") 'Connect
sDatabase="Driver={SQL Server};Server=testing.intgdb.testthis.com;DATABASE=MainQA;UID=jcc26;Password=******"
sConnect.open (sDatabase)
sSQL="Select Guid1 from dbo.pat inner join dbo.SurveyPat on dbo.pat.pat_id=dbo.SurveyPat.pat_ids where email = 'test9901@mailinator.com'"
Set sRecord = sConnect.Execute(sSQL)
sGUID = sRecord.GetString
sURL = "https://test.test.net/survey.aspx?sid="&sGUID
msgbox sURL 'for testing
So, I expect:

https://test.test.net/survey.aspx?sid=123-234-456
But I am getting:

https://test.test.net/survey.aspx?sid={123-234-456}

Anyone have any ideas why?


RE: Using GetString to pull information from a DB - jcraig26 - 10-31-2012

Used mid() to accomplish this.


RE: Using GetString to pull information from a DB - SteveS - 11-02-2012

What happens if you try retrieving the guid using the field name:

Code:
sGUID = sRecord.Fields("Guid1")