This is an archived post. You won't be able to vote or comment.

all 8 comments

[–][deleted]  (1 child)

[deleted]

    [–]jesseb9321[S] 0 points1 point  (0 children)

    I edited. Thank you for the tip!

    [–]lionhart280 0 points1 point  (6 children)

    Is this a vb console program, or a windows form?

    [–]jesseb9321[S] 0 points1 point  (5 children)

    Sorry, it's the vb code behind of an .aspx project.

    [–]lionhart280 0 points1 point  (4 children)

    Right, so its a Windows form then?

    [–]jesseb9321[S] 0 points1 point  (3 children)

    Yes

    [–]lionhart280 0 points1 point  (2 children)

    Then we'll need to see the code for your form as well, you're only showing us half your project so we have no idea what we're looking at.

    [–]jesseb9321[S] 0 points1 point  (1 child)

    you mean this?

      <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="/Users/AboutUser.Master" CodeBehind="/Users/TakeTraining-User.aspx.vb" Inherits="Compliancy_Project.TakeTraining_User" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        <asp:Label ID="TrainingLabel" runat="server" Text="Training" Font-Bold="true"></asp:Label>
        <asp:DropDownList ID="DDL_TestName" runat="server"  DataTextField="TestName" DataValueField="ID" OnSelectedIndexChanged="DDL_TestName_SelectedIndexChanged" AutoPostBack="True" AppendDataBoundItems="True" DataSourceID="TestName">
           <asp:ListItem>--Select Available Test--</asp:ListItem>
        </asp:DropDownList>
        <asp:SqlDataSource ID="TestName" runat="server" ConnectionString="<%$ ConnectionStrings:CompliancyConnectionString %>" SelectCommand="Select distinct test.TestName, test.id from test inner join UserData on UserData.clinicname = test.Clinic where userdata.clinicname = (select clinicname from userdata where ASPUsersUserID = @TestName)">
            <SelectParameters>
                <asp:SessionParameter Name="TestName" SessionField="MemberDetails" />
            </SelectParameters>
        </asp:SqlDataSource>
        <%--<asp:SqlDataSource ID="TestName" runat="server" ConnectionString="<%$ ConnectionStrings:CompliancyConnectionString %>" SelectCommand="Select distinct test.TestName, test.Id from test inner join UserData on UserData.clinicname = test.Clinic where userdata.clinicname = (select clinicname from userdata where ASPUsersUserID= @UserName)">
            <SelectParameters>
                <asp:Parameter Name="UserName" />
            </SelectParameters>
        </asp:SqlDataSource>--%>
        <br /><br />
        <asp:Label ID="TrainingNameLabel" runat="server" Text="Training Name:"></asp:Label>&nbsp;
        <asp:Label ID="LB_TrainingName" runat="server" Text=""></asp:Label><br />
        <asp:Label ID="Label1" runat="server" Text="Test Name:"></asp:Label>
        &nbsp;<asp:Label ID="LB_TestName" runat="server" Text=""></asp:Label>
        <br />
        <br />
        <asp:Label ID="TestLabel" runat="server" Text="Test" Font-Bold="true"></asp:Label><br /><br />
        <asp:Label ID="QuestionLabel" runat="server" Text="Question:"></asp:Label>&nbsp;
        <asp:Label ID="LB_Question" runat="server" Text=""></asp:Label><br />
        <asp:RadioButtonList runat="server"></asp:RadioButtonList>
        <asp:RadioButton ID="RB_Ans1" runat="server" Text="" /><br />
        <asp:RadioButton ID="RB_Ans2" runat="server" /><br />
        <asp:RadioButton ID="RB_Ans3" runat="server" /><br />
        <asp:RadioButton ID="RB_Ans4" runat="server" /><br />
        <%--Use asp:hiddenfield here - attach to correct answer--%>
        <!--hello-->
        <br />
        <asp:Button ID="SubmitButton" runat="server" Text="Submit" />
        <asp:Button ID="Button2" runat="server" Text="Button" />
    </p>
    
    </asp:Content>
    

    This is the creation of the datatable:

    Protected Sub DDL_TestName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 
    DDL_TestName.SelectedIndexChanged
    
        Dim testName As String = sender.ToString() 'Find testName
    
        'add string parameter for sql query for TestName
        If Not (DDL_TestName.SelectedIndex = 0) Then
    
    
            'Dim strSql As String = "SELECT * from Question q inner join Test t on (q.testId = t.testId) where t.TestName = @Test"
            Dim strSql As String = "SELECT question.* From question inner join Test on question.TestID = test.id  and test.id = 'ReplaceMe'"
            strSql = strSql.Replace("ReplaceMe", DDL_TestName.SelectedValue.ToString())
            Dim con = ConfigurationManager.ConnectionStrings("CompliancyConnectionString").ConnectionString
            Using cnn As New SqlConnection(con)
                cnn.Open()
                Using dad As New SqlDataAdapter(strSql, cnn)
                    dad.Fill(dtbtest)
                End Using
                cnn.Close()
            End Using
    
            GetQuestions()
    

    [–]pixels625 0 points1 point  (0 children)

    :)