Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/forums/asp/)
-   -   inserting into an access database (http://www.go4expert.com/forums/inserting-access-database-t10047/)

milly999 15Apr2008 15:27

inserting into an access database
 
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 Code:

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



All times are GMT +5.5. The time now is 01:20.