1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

inserting into an access database

Discussion in 'ASP' started by milly999, Apr 15, 2008.

  1. milly999

    milly999 New Member

    Joined:
    Apr 14, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student / Web Developer / Designer
    Location:
    Wales, UK
    hi everyone i was wondring if anyone could help me please! i used this code the other day and it was working fine, but then i put this required field validator in and now the sqldatasource is only inserting null values into my database! can someone help me out PLEASE!!!
    HTML:
    <SCRIPT runat="server">
        Private Sub InsertVote(ByVal Source As Object, ByVal e As EventArgs)
            SqlDataSource1.Insert()
        End Sub    
    </SCRIPT>
    <form id="form1" runat="server">   	 
        Please can you enter your Account ID into the box below, then select the party you wish to vote for by clicking the down arrow and navigatinging to the party of your choice then click the Submit button.
         <br /> 
         <br />
      Account ID: <asp:TextBox id="TextBox1" runat="server"/> 
       <br />     
     	 <asp:RequiredFieldValidator ID="Validator1" 
     	 ControlToValidate="TextBox1" ErrorMessage="Please enter your account number" 
     	 runat="server"  /> 	 
           <br /> <br />
         Party Selection: 
         <asp:dropdownlist id="Dropdownlist1" runat="server" datasourceid="SqlDataSource1" datatextfield="Party" AppendDataBoundItems="true">
        <asp:ListItem Value="" Text="Please Select"/>
        </asp:dropdownlist> 
        <br />
        <asp:RequiredFieldValidator ID="Validator2" ControlToValidate="Dropdownlist1"
        ErrorMessage="Please can you select the party you wish to vote for" runat="server"/>
     <br />
          <asp:sqldatasource
            id="SqlDataSource1"
            runat="server" 
            selectcommand="SELECT Party.Party FROM Party"
            insertcommand="INSERT INTO Vote(AccountId,Vote) VALUES (Account,Vote)" 
            ConnectionString="<%$ ConnectionStrings:VotingConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:VotingConnectionString.ProviderName %>">
            <InsertParameters>
            <asp:FormParameter Name="Account" Type="String" FormField="AccountNumber" /> 
            <asp:FormParameter Name="Party" Type="String" FormField="PartyList"   />
                           
            </InsertParameters>      
            </asp:sqldatasource>     
            <br />
     
            <asp:button id="Button1" runat="server" text="Submit"  onclick="InsertVote"/> 
               
         </form>
     
    Last edited by a moderator: Apr 16, 2008

Share This Page