Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net update database from drop down list
    primarykey
    data
    text
    <p>I'm trying to allow a user select their marital status that will update a field in a database. This is fine when it is the user's first time, but if they want to update it again, it will not update.</p> <p>If I choose a data source, if they wish to update, they aren't given any other options in the DDL other that what was selected the first time.</p> <p><em><strong></em>*</strong><em>ASPX</em><strong><em>*</em></strong></p> <pre><code>&lt;asp:DropDownList ID="DDLMarital" runat="server" TabIndex="1"&gt; &lt;asp:ListItem Value = "Single" Text = "Single"&gt;Single&lt;/asp:ListItem&gt; &lt;asp:ListItem Value = "Married" Text = "Married"&gt;Married&lt;/asp:ListItem&gt; &lt;asp:ListItem Value = "Separated" Text = "Separated"&gt;Separated&lt;/asp:ListItem&gt; &lt;asp:ListItem Value = "Divorced" Text = "Divorced"&gt;Divorced&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <p><em><strong></em>**<em>*</em>*</strong><em>ASPX.VB</em><strong><em>*</em>****</strong></p> <pre><code>'binding... </code></pre> <p>Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load</p> <pre><code> Dim dvSql4 As DataView = DirectCast(SqlMarital.Select(DataSourceSelectArguments.Empty), DataView) For Each drvSql4 As DataRowView In dvSql4 DDLMarital.Text = drvSql4("Marital_Status").ToString() Next </code></pre> <p>End Sub</p> <p>'updating the database when the "Next" button is clicked Protected Sub BtnNext_Click(sender As Object, e As System.EventArgs) Handles BtnNext.Click</p> <pre><code> Dim con As New SqlConnection Dim cmd As New SqlCommand con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\scrummingit2.mdf;Integrated Security=True;User Instance=True" con.Open() cmd.Connection = con cmd.CommandText = ("UPDATE Student_Personal_Details SET Marital_Status = @Marital WHERE Student_No = @StudentNo") Dim maritalParam As New SqlParameter("@Marital", DDLMarital.Text) Dim studentNoParam As New SqlParameter("@StudentNo", lblEnrolmentStudentNumber.Text) lblEnrolmentStudentNumber.Text = Session("Student") cmd.Parameters.Add(maritalParam) cmd.Parameters.Add(studentNoParam) cmd.ExecuteNonQuery() con.Close() </code></pre> <p>End Sub</p> <p>Can anyone help? Getting desperate now after days of not finding any answers on Google.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload