Note that there are some explanatory texts on larger screens.

plurals
  1. POProcedure not updating the data in the database
    primarykey
    data
    text
    <p>this is my asp code:</p> <pre><code>&lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:GridView ID="GridView1" runat="server"&gt; &lt;Columns&gt; &lt;asp:CommandField ShowEditButton="True" /&gt; &lt;asp:TemplateField HeaderText="Id" InsertVisible="False"&gt; &lt;EditItemTemplate&gt; &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("id") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblId" runat="server" Text='&lt;%# Bind("id") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="firstname"&gt; &lt;EditItemTemplate&gt; &lt;asp:TextBox ID="TextBox2" runat="server" Text='&lt;%# Bind("firstname") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lbl" runat="server" Text='&lt;%# Bind("firstname") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p></p> <p>and this is my vb code:</p> <pre><code>Imports System.Data.SqlClient Imports System.Data Partial Class testt Inherits System.Web.UI.Page Public connectionString As String = ConfigurationManager.ConnectionStrings("TestConnectionString").ConnectionString Public cn As SqlConnection = New SqlConnection(connectionString) Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim ds As New DataSet Dim dt As New DataTable If cn.State = ConnectionState.Closed Then cn.Open() End If Dim command As SqlCommand = New SqlCommand("selecttest", cn) command.CommandType = CommandType.StoredProcedure Dim da As New SqlDataAdapter(command) da.Fill(ds, "testtt") dt = ds.Tables(0) GridView1.DataSource = dt If Not IsPostBack Then GridView1.DataBind() End If If cn.State = ConnectionState.Open Then cn.Close() End If End Sub Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating Dim strPersonID As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("TextBox1"), TextBox).Text Dim strLastName As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("TextBox2"), TextBox).Text Try Dim command As SqlCommand = New SqlCommand("updatetest", cn) command.CommandType = CommandType.StoredProcedure command.Parameters.AddWithValue("@pid", strPersonID) command.Parameters.AddWithValue("@pfirstname", strLastName) If cn.State = ConnectionState.Closed Then cn.Open() End If command.ExecuteNonQuery() MsgBox("1 row updated") If cn.State = ConnectionState.Open Then cn.Close() End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub Public Sub GridView1_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing GridView1.EditIndex = e.NewEditIndex If Not IsPostBack Then GridView1.DataBind() End If End Sub End Class </code></pre> <p>1- the columns in the grid is duplicated which means that I'm getting the selected data from the stored procedure and the data binded in the template fields in new columns so instead of getting just 2 columns I'm getting 4 having the same data so how can i fix this?</p> <p>2-no errors in the rowupdating event everything is working fine but the data is not being updated in the database. Note that the stored procedure is working fine in SQL.. it may be cause because of the duplicated columns mentioned before...</p> <p>any help?? </p> <p>thank you !</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