Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

 

This is a snippet of my code. What I am trying to do is use strTableQuery to assign the table name I want to search through. It could be SystemName, Type, etc. Basically any of the table names.

 

When I run this the value of strTableQuery isn't being set into the strSqlQuery.

 

I.E. During Runtime

strSqlQuery = "SELECT * from PermanentAssets WHERE strTableQuery = '*'"

where I want it to equal.

strSqlQuery = "SELECT * from PermanentAssets WHERE WallPortNo = '*'"

 

Is it possible to do this? If so what am I doing wrong?

 

Thank you in advance for your help.

 

Dim strSqlQuery As String
Dim strTableQuery As String

strTableQuery = "WallPortNo"
strSqlQuery = "SELECT * from PermanentAssets WHERE strTableQuery = '*'"

' Retrieve all the Permanent Asset Information
daDataAdapter = New OleDb.OleDbDataAdapter(strSqlQuery, cnAdoNetConnection)

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

Posted

You have:

 

strTableQuery = "WallPortNo"

strSqlQuery = "SELECT * from PermanentAssets WHERE strTableQuery = '*'"

 

 

You need to change that to the variable:

 

strTableQuery = "WallPortNo"

strSqlQuery = "SELECT * from PermanentAssets WHERE " + strTableQuery + "= '*'"

Posted

That works well.

 

Ok next question then. If I want to set the '*'"

 

strSqlQuery = "SELECT * from PermanentAssets WHERE " + strTableQuery + "= '*'"

 

to a string how would I do that.

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

Posted

Not to worry figured it out with a bit of playing around.

 

strSqlQuery = "SELECT * from PermanentAssets WHERE " + strTableQuery + "= '" + strTableTest + "'"

 

Thanks for your help.

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

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...