Click here to Skip to main content
15,434,078 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Odd Transparency behavior in VB.Net Panel Pin
Peter R. Fletcher6-Aug-21 10:01
MemberPeter R. Fletcher6-Aug-21 10:01 
GeneralRe: Odd Transparency behavior in VB.Net Panel Pin
Gerry Schmitz7-Aug-21 5:38
mveGerry Schmitz7-Aug-21 5:38 
QuestionPassing PointF as Optional Parameter Pin
SanganakSakha28-Jul-21 21:06
MemberSanganakSakha28-Jul-21 21:06 
AnswerRe: Passing PointF as Optional Parameter Pin
Richard Deeming28-Jul-21 21:30
mveRichard Deeming28-Jul-21 21:30 
GeneralVisual Basic Scripts Pin
Luis M. Rojas28-Jul-21 13:12
MemberLuis M. Rojas28-Jul-21 13:12 
AnswerRe: Visual Basic Scripts Pin
Richard Deeming28-Jul-21 21:27
mveRichard Deeming28-Jul-21 21:27 
GeneralRe: Visual Basic Scripts Pin
Luis M. Rojas29-Jul-21 2:26
MemberLuis M. Rojas29-Jul-21 2:26 
GeneralRe: Visual Basic Scripts Pin
Richard Deeming29-Jul-21 2:50
mveRichard Deeming29-Jul-21 2:50 
You can read query-string parameters by accessing the Request.QueryString collection - eg:
VBScript
Dim sAgencia
sAgencia = Request.QueryString("agencia")
You can test whether a value was passed by calling Len:
VBScript
If Len(sAgencia) <> 0 Then
   ...
End If
If a value is passed, you would need to add an additional filter to your query. However, you need to pass the value as a parameter to avoid a SQL Injection[^] vulnerability. This will complicate your code slightly - for example:
VBScript
Sub getSucursalesJSON()
Dim sSqlWrk, rswrk, cmd
Dim sAgencia, pAgencia

    Set cmd = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = conn
    cmd.CommandType = adCmdText

    sSqlWrk = "SELECT ..."
    sSqlWrk = sSqlWrk & " FROM ..."
    sSqlWrk = sSqlWrk & " WHERE ..."
    sSqlWrk = sSqlWrk & " And ..."
    
    sAgencia = Request.QueryString("agencia")
    If Len(sAgencia) <> 0 Then
        ' TODO: Specify the correct data type and size to match your column:
        Set pAgencia = cmd.CreateParameter("agencia", adVarChar, adParamInput, 100, sAgencia)
        cmd.Parameters.Append pAgencia
        
        ' TODO: Specify the correct table and column name for your filter:
        sSqlWrk = sSqlWrk & " And (x.agencia = ?)"
    End If
    
    sSqlWrk = sSqlWrk & " ORDER BY ..."
    
    cmd.CommandText = sSqlWrk
    
    Set rswrk = cmd.Execute()
    oJSON.LoadRecordset rswrk
    
    Set rswrk = Nothing
    Set pAgencia = Nothing
    Set cmd = Nothing
    
    oJSON.Write()
End Sub
To reference the ADODB constants, you will need to make sure the file includes the adovbs.inc directive towards the top:
ASP
<!--#include File="adovbs.inc"-->

VBScript ADO Programming - ActiveX Data Objects (ADO) | Microsoft Docs[^]
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Visual Basic Scripts Pin
Luis M. Rojas29-Jul-21 3:20
MemberLuis M. Rojas29-Jul-21 3:20 
GeneralRe: Visual Basic Scripts Pin
Richard Deeming29-Jul-21 3:26
mveRichard Deeming29-Jul-21 3:26 
GeneralRe: Visual Basic Scripts Pin
Luis M. Rojas2-Aug-21 5:27
MemberLuis M. Rojas2-Aug-21 5:27 
GeneralRe: Visual Basic Scripts Pin
jsc422-Aug-21 7:04
professionaljsc422-Aug-21 7:04 
GeneralRe: Visual Basic Scripts Pin
Luis M. Rojas2-Aug-21 8:14
MemberLuis M. Rojas2-Aug-21 8:14 
QuestionMissing Controls After Office 2019 Installation Pin
Ken Kazinski11-Jul-21 2:16
professionalKen Kazinski11-Jul-21 2:16 
AnswerRe: Missing Controls After Office 2019 Installation Pin
Eddy Vluggen11-Jul-21 6:56
professionalEddy Vluggen11-Jul-21 6:56 
AnswerRe: Missing Controls After Office 2019 Installation Pin
Gerry Schmitz11-Jul-21 7:09
mveGerry Schmitz11-Jul-21 7:09 
GeneralRe: Missing Controls After Office 2019 Installation Pin
Ken Kazinski12-Jul-21 16:40
professionalKen Kazinski12-Jul-21 16:40 
GeneralRe: Missing Controls After Office 2019 Installation Pin
Gerry Schmitz13-Jul-21 7:23
mveGerry Schmitz13-Jul-21 7:23 
AnswerRe: Missing Controls After Office 2019 Installation Pin
CHill6015-Jul-21 2:29
mveCHill6015-Jul-21 2:29 
AnswerRe: Missing Controls After Office 2019 Installation Pin
jsc4215-Jul-21 3:07
professionaljsc4215-Jul-21 3:07 
GeneralRe: Missing Controls After Office 2019 Installation Pin
Ken Kazinski18-Jul-21 3:07
professionalKen Kazinski18-Jul-21 3:07 
AnswerRe: Missing Controls After Office 2019 Installation Pin
Ken Kazinski18-Jul-21 3:09
professionalKen Kazinski18-Jul-21 3:09 
QuestionProject building Pin
Anthony Yawson10-Jul-21 23:59
MemberAnthony Yawson10-Jul-21 23:59 
GeneralRe: Project building Pin
Richard MacCutchan11-Jul-21 2:47
mveRichard MacCutchan11-Jul-21 2:47 
AnswerRe: Project building Pin
Dave Kreskowiak11-Jul-21 5:47
mveDave Kreskowiak11-Jul-21 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.