Click to See Complete Forum and Search --> : records getting saved 2 times in database


shivkumar
January 28th, 2008, 08:19 AM
I have designed a web page in ASP.net and using VB as script language.
I have kept the coding details in separate page(form.aspx.vb).

when I am saving the record in database, it is getting two times (sql express database). Here is the coding..

Protected Sub CMD_SAVE_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMD_SAVE.Click
Dim ds As New DataSet
Dim dr As DataRow
selstr = "Select * from travel_dtls"
da = New SqlDataAdapter(selstr, sqlcon)
da.Fill(ds, "travel_dtls")
dr = ds.Tables("travel_dtls").NewRow()
dr.Item("tvl_from1") = TXTFROM.Text
dr.Item("tvl_to1") = TXTTO.Text
da.InsertCommand = (New SqlCommandBuilder(da)).GetInsertCommand()
ds.Tables("travel_dtls").Rows.Add(dr)
da.Update(ds, "travel_dtls")

when I modified the first line and removed "handles cmd_save.click",
(now it is only "Protected Sub CMD_SAVE_Click(ByVal sender As Object, ByVal e As System.EventArgs), I found that record is not getting updated two times. now it is only one time.

Can any one guide me what could be the reason and how it works.is theere any specific logic behind this.

I am learning ASP.net on my own and recently started.