1

I've spent way too long trying to figure out the answer to this question, so I thought it was time to ask. I'm trying to pass a value that the user input on the previous page into a sql query. I've tried every possible way I could find online to do this, but I just can't get it to work. In the _ space, I've tried

"'& myAge & '" " + myAge " & myAge @myAge $myAge

Pretty much every combination of quotes with @,&,and +, and I just cannot get it to work. I am not a web developer, but I'm working on an web app for my job and I could really use some help getting past this roadblock.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="gridview.aspx.vb" Inherits="TestWebsite.gridview" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
  <%
      Dim myAge
      myAge = Request.Form("inputAge")

%>

    Age: <%= myAge%>

    <form id="form1" runat="server">
    <div>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cs_test website %>" SelectCommand="SELECT * FROM [OARiskData$] WHERE AGE= _________"></asp:SqlDataSource>

        <br />
        <br />
        <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
        </asp:GridView>

    </div>
    </form>
    <p>
        &nbsp;</p>
</body>
</html>

1 Answer 1

2
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cs_test website %>" 
    SelectCommand="SELECT * FROM [OARiskData$] WHERE AGE= @Age">
    <SelectParameters>
        <asp:FormParameter DefaultValue="" Name="Age" FormField="inputAge" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>
Sign up to request clarification or add additional context in comments.

1 Comment

If it's in Request.Form(), this should see it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.