Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I need some help with this:

 

I am trying to build an sql query in a string and I am having a hard time getting the end quote on the string! I've tried this:

 

sQuery = "select myfield from mytable where thisvalue= '" & sMyVariable & "'"

 

and I've tried:

 

sQuery = [string].concat("select myfield from mytable where thisvalue = '", sMyVariable, "'")

 

BOTH of them result in the following string

 

select myfield from mytable where thisvalue = 'thevalueofthevar

 

With NO end quote!! This is of course causing my sql query to fail. The variable sQuery is long enough. Please help!

 

Frances

Posted

Here is the code:

 

sAccountno = New String(Chr(0), 22)
GMW_DB_Read(lWA, "Accountno", sAccountno, 22)
GMW_DB_Delete(lWA)
GMW_DB_Close(lWA)

lWA = GMW_DB_Open("Contact2")
GMW_DB_SetOrder(lWA, "CONTACT2")
iResult = GMW_DB_Seek(lWA, sAccountno)

If iResult = 1 Then
    GMW_DB_Delete(lWA)
End If

GMW_DB_Close(lWA)

sQuery = New String(Chr(0), 256)

sQuery = [string].Concat("select recid from contsupp where accountno = '", sAccountno, "'")

 

sAccount is declared as a string. And Robby, I know that numeric values in an sql query do not have quotes around them. That has nothing to do with my question. I need quotes around this value, but the trailing quote is not showing up.

Posted
That's just lame. The concat should append up to the null in sAccountno and then add on the end quote. It worked fine in VB6. How do I strip the end nulls from the sAccountno?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...