locked
Unable to insert data in table RRS feed

  • Question

  • User1601006133 posted

    Hello

    I have a table called Fish in the database with the following connection string in the webconfig file:

    <connectionStrings>
          <add name="SQLDbConnection"
          connectionString="Server=RO0107116W1; Database=Aquarius; User ID=sa; Password=Azerty123!"
          providerName="System.Data.SqlClient" />
    </connectionStrings>

    In this table I had a few string columns, an integer column (ID) and an image column. I was able to insert data from aspx page in the table on click (the image was converted to binary data).

    Since I had troubles displaying the image from the database and because the users want to upload big images (up to 1 MB), I deleted all the rows from the Fish table, I deleted the image column and from the code I deleted all the parts referring the image column. The image is now uploaded in a file directory.

    The problem is I have no error when adding new fish, the image is uploaded on the server directory, but nothing is written in the database. Here is my page now:

    Imports System.Data.SqlClient
    Imports System.Web.HttpContext
    Imports System.Data
    Imports System.Configuration
    Imports System.IO
    
    Partial Class _Aquarius
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                FishGridView.DataSource = GetData("SELECT Name,Owner,Type,Gender,Description,ID FROM Fish")
                FishGridView.DataBind()
            End If
            If Not IsPostBack Then
                divAddFish.Visible = False
                SubmitStatus.Text = ""
            End If
        End Sub
    
        Public Sub ReturnChat_Click(sender As Object, e As EventArgs)
            Response.Redirect("Default.aspx")
        End Sub
    
        Public Sub AddFish_Click(sender As Object, e As EventArgs)
            divAddFish.Visible = True
            SubmitStatus.Text = ""
        End Sub
    
        Public Sub SubmitFish_Click(sender As Object, e As EventArgs)
            If FishUpload.HasFile Then
                divAddFish.Visible = False
                Dim imgLen As Integer = FishUpload.PostedFile.ContentLength
                Dim strFileExt As String = System.IO.Path.GetExtension(FishUpload.FileName).ToLower().Substring(1, 3)
                If strFileExt = "jpg" OrElse strFileExt = "png" OrElse strFileExt = "gif" Then
                    If imgLen <= 42151 Then
                        'Create the connection
                        Dim con As New SqlConnection()
                        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
                        con.Open()
                        Dim cmd As New SqlCommand()
                        cmd.CommandText = "select max(ID) from Fish"
                        cmd.Connection = con
                        Dim MaxID As Integer
                        If Not IsDBNull(cmd.ExecuteScalar) Then
                            MaxID = cmd.ExecuteScalar()
                        Else
                            MaxID = 0
                        End If
                        Dim da As New SqlDataAdapter("[dbo].[AddToFish]", con)
                        da.SelectCommand.CommandType = CommandType.StoredProcedure
                        da.SelectCommand.Parameters.Add(New SqlParameter("@Name", SqlDbType.Text))
                        da.SelectCommand.Parameters("@Name").Value = TextBoxName.Text
                        da.SelectCommand.Parameters.Add(New SqlParameter("@Owner", SqlDbType.Text))
                        da.SelectCommand.Parameters("@Owner").Value = TextBoxOwner.Text
                        da.SelectCommand.Parameters.Add(New SqlParameter("@Type", SqlDbType.Text))
                        da.SelectCommand.Parameters("@Type").Value = TextBoxType.Text
                        da.SelectCommand.Parameters.Add(New SqlParameter("@Gender", SqlDbType.Text))
                        da.SelectCommand.Parameters("@Gender").Value = TextBoxGender.Text
                        da.SelectCommand.Parameters.Add(New SqlParameter("@Description", SqlDbType.Text))
                        da.SelectCommand.Parameters("@Description").Value = TextBoxDescription.Text
                        da.SelectCommand.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int))
                        da.SelectCommand.Parameters("@ID").Value = MaxID + 1
                        Dim fileName As String = (MaxID + 1).ToString & "." & strFileExt
                        FishUpload.PostedFile.SaveAs("\\RO0107116W1\Users\Public\Documents\Images\" + fileName)
                        Response.Redirect(Request.Url.AbsoluteUri)
                        da.SelectCommand.ExecuteNonQuery()
                        con.Dispose()
                    Else
                        ClientScript.RegisterStartupScript([GetType](), "message", "alert('41 KB size file is allowed');", True)
                    End If
                Else
                    ClientScript.RegisterStartupScript([GetType](), "message", "alert('Only jpg,.png,.gif files are allowed');", True)
                End If
            Else
                ClientScript.RegisterStartupScript([GetType](), "message", "alert('Please select a file');", True)
            End If
        End Sub
    
        Private Function GetData(query As String) As DataTable
            Dim dt As New DataTable()
            Dim constr As String = ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
            Using con As New SqlConnection(constr)
                Using cmd As New SqlCommand(query)
                    Using sda As New SqlDataAdapter()
                        cmd.CommandType = CommandType.Text
                        cmd.Connection = con
                        sda.SelectCommand = cmd
                        sda.Fill(dt)
                    End Using
                End Using
                Return dt
            End Using
        End Function
    
    End Class
    

    I don't know if I have messed up something when I deleted the image column...
    Here is the AddtoFish stored procedure which used to work before deleting the image column:

    USE [Aquarius]
    GO
    /****** Object: StoredProcedure [dbo].[AddToFish] Script Date: 03/11/2014 21:46:49 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: Alexandru Cojocaru
    -- Create date: 10/23/2014
    -- Description: Adds fishes to Aquarius
    -- =============================================
    ALTER PROCEDURE [dbo].[AddToFish] 
    -- Add the parameters for the stored procedure here
    @Name text = NULL, 
    @Owner text = NULL,
    @Type text = NULL,
    @Gender text = NULL,
    @Description text = NULL,
    @ID int = NULL
    AS
    BEGIN
    INSERT INTO dbo.Fish(Name,Owner,Type,Gender,Description,ID) values(@Name,@Owner,@Type,@Gender,@Description,@ID);
    END

    The MSSQL services are running, In the SQL server management studio the connection is "green"

    When I run the DELETE FROM Fish; query it returns "0 rows affected" so I suppose there are no rows. However when I run SELECT COUNT(*) FROM Fish; it returns 1 row...

    All the columns require data and there is no default value.

    Thank you and Regards,

    Alex

    Monday, November 3, 2014 3:58 PM

Answers

  • User724169276 posted

    Thats because you are redirecting before executing the command.

     Response.Redirect(Request.Url.AbsoluteUri)
     cmd2.ExecuteNonQuery()

    See :

    Imports System.Data.SqlClient
    Imports System.Web.HttpContext
    Imports System.Data
    Imports System.Configuration
    Imports System.IO
    
    Partial Class _Aquarius
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                FishGridView.DataSource = GetData("SELECT Name,Owner,Type,Gender,Description,ID FROM Fish2")
                FishGridView.DataBind()
            End If
            If Not IsPostBack Then
                divAddFish.Visible = False
                SubmitStatus.Text = ""
            End If
        End Sub
    
        Public Sub ReturnChat_Click(sender As Object, e As EventArgs)
            Response.Redirect("Default.aspx")
        End Sub
    
        Public Sub AddFish_Click(sender As Object, e As EventArgs)
            divAddFish.Visible = True
            SubmitStatus.Text = ""
        End Sub
    
        Public Sub SubmitFish_Click(sender As Object, e As EventArgs)
            If FishUpload.HasFile Then
                divAddFish.Visible = False
                Dim imgLen As Integer = FishUpload.PostedFile.ContentLength
                Dim strFileExt As String = System.IO.Path.GetExtension(FishUpload.FileName).ToLower().Substring(1, 3)
                If strFileExt = "jpg" OrElse strFileExt = "png" OrElse strFileExt = "gif" Then
                    If imgLen <= 42151 Then
                        'Create the connection
                        Dim con As New SqlConnection()
                        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
                        con.Open()
                        Dim cmd As New SqlCommand()
                        Dim cmd2 As New SqlCommand()
                        cmd.CommandText = "SELECT MAX(ID) FROM Fish2"
                        cmd2.CommandText = "INSERT INTO Fish2(Name,Owner,Type,Gender,Descriptionn,ID) VALUES (@Name,@Owner,@Type,@Gender,@Description,@ID)"
                        cmd.Connection = con
                        cmd2.Connection = con
                        Dim MaxID As Integer
                        If Not IsDBNull(cmd.ExecuteScalar) Then
                            MaxID = cmd.ExecuteScalar()
                        Else
                            MaxID = 0
                        End If
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Name", SqlDbType.Text)).Value = TextBoxName.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Owner", SqlDbType.Text)).Value = TextBoxOwner.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Type", SqlDbType.Text)).Value = TextBoxType.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Gender", SqlDbType.Text)).Value = TextBoxGender.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Description", SqlDbType.Text)).Value = TextBoxDescription.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@ID", SqlDbType.Int)).Value = MaxID + 1
                        Dim fileName As String = (MaxID + 1).ToString & "." & strFileExt
                        FishUpload.PostedFile.SaveAs("\\RO0107116W1\Users\Public\Documents\Images\" + fileName)
                        cmd2.ExecuteNonQuery()                    
    con.Dispose(); Response.Redirect(Request.Url.AbsoluteUri) Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('41 KB size file is allowed');", True) End If Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('Only jpg,.png,.gif files are allowed');", True) End If Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('Please select a file');", True) End If End Sub Private Function GetData(query As String) As DataTable Dim dt As New DataTable() Dim constr As String = ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString Using con As New SqlConnection(constr) Using cmd As New SqlCommand(query) Using sda As New SqlDataAdapter() cmd.CommandType = CommandType.Text cmd.Connection = con sda.SelectCommand = cmd sda.Fill(dt) End Using End Using Return dt End Using End Function End Class

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 4, 2014 8:47 AM

All replies

  • User2103319870 posted

    You need to change the SQLDataAdapter SelectCommand to InsertCommand like given below

    Public Sub SubmitFish_Click(sender As Object, e As EventArgs)
            If FishUpload.HasFile Then
                divAddFish.Visible = False
                Dim imgLen As Integer = FishUpload.PostedFile.ContentLength
                Dim strFileExt As String = System.IO.Path.GetExtension(FishUpload.FileName).ToLower().Substring(1, 3)
                If strFileExt = "jpg" OrElse strFileExt = "png" OrElse strFileExt = "gif" Then
                    If imgLen <= 42151 Then
                        'Create the connection
                        Dim con As New SqlConnection()
                        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
                        con.Open()
                        Dim cmd As New SqlCommand()
                        cmd.CommandText = "select max(ID) from Fish"
                        cmd.Connection = con
                        Dim MaxID As Integer
                        If Not IsDBNull(cmd.ExecuteScalar) Then
                            MaxID = cmd.ExecuteScalar()
                        Else
                            MaxID = 0
                        End If
                        Dim da As New SqlDataAdapter("[dbo].[AddToFish]", con)
                        da.InsertCommand.CommandType = CommandType.StoredProcedure
                        da.InsertCommand.Parameters.Add(New SqlParameter("@Name", SqlDbType.Text))
                        da.InsertCommand.Parameters("@Name").Value = TextBoxName.Text
                        da.InsertCommand.Parameters.Add(New SqlParameter("@Owner", SqlDbType.Text))
                        da.InsertCommand.Parameters("@Owner").Value = TextBoxOwner.Text
                        da.InsertCommand.Parameters.Add(New SqlParameter("@Type", SqlDbType.Text))
                        da.InsertCommand.Parameters("@Type").Value = TextBoxType.Text
                        da.InsertCommand.Parameters.Add(New SqlParameter("@Gender", SqlDbType.Text))
                        da.InsertCommand.Parameters("@Gender").Value = TextBoxGender.Text
                        da.InsertCommand.Parameters.Add(New SqlParameter("@Description", SqlDbType.Text))
                        da.InsertCommand.Parameters("@Description").Value = TextBoxDescription.Text
                        da.InsertCommand.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int))
                        da.InsertCommand.Parameters("@ID").Value = MaxID + 1
                        Dim fileName As String = (MaxID + 1).ToString & "." & strFileExt
                        FishUpload.PostedFile.SaveAs("\\RO0107116W1\Users\Public\Documents\Images\" + fileName)
                        Response.Redirect(Request.Url.AbsoluteUri)
                        da.InsertCommand.ExecuteNonQuery()
                        con.Dispose()
                    Else
                        ClientScript.RegisterStartupScript([GetType](), "message", "alert('41 KB size file is allowed');", True)
                    End If
                Else
                    ClientScript.RegisterStartupScript([GetType](), "message", "alert('Only jpg,.png,.gif files are allowed');", True)
                End If
            Else
                ClientScript.RegisterStartupScript([GetType](), "message", "alert('Please select a file');", True)
            End If
        End Sub

    Monday, November 3, 2014 4:17 PM
  • User1601006133 posted

    Hello, thank you for answering.

    If I do it I get the following error for any of the InsertCommand lines:

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Monday, November 3, 2014 4:32 PM
  • User1601006133 posted

    I modified the code as following, same problem: no error but no data inserted in the database table:

    Imports System.Data.SqlClient
    Imports System.Web.HttpContext
    Imports System.Data
    Imports System.Configuration
    Imports System.IO
    
    Partial Class _Aquarius
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                FishGridView.DataSource = GetData("SELECT Name,Owner,Type,Gender,Description,ID FROM Fish2")
                FishGridView.DataBind()
            End If
            If Not IsPostBack Then
                divAddFish.Visible = False
                SubmitStatus.Text = ""
            End If
        End Sub
    
        Public Sub ReturnChat_Click(sender As Object, e As EventArgs)
            Response.Redirect("Default.aspx")
        End Sub
    
        Public Sub AddFish_Click(sender As Object, e As EventArgs)
            divAddFish.Visible = True
            SubmitStatus.Text = ""
        End Sub
    
        Public Sub SubmitFish_Click(sender As Object, e As EventArgs)
            If FishUpload.HasFile Then
                divAddFish.Visible = False
                Dim imgLen As Integer = FishUpload.PostedFile.ContentLength
                Dim strFileExt As String = System.IO.Path.GetExtension(FishUpload.FileName).ToLower().Substring(1, 3)
                If strFileExt = "jpg" OrElse strFileExt = "png" OrElse strFileExt = "gif" Then
                    If imgLen <= 42151 Then
                        'Create the connection
                        Dim con As New SqlConnection()
                        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
                        con.Open()
                        Dim cmd As New SqlCommand()
                        Dim cmd2 As New SqlCommand()
                        cmd.CommandText = "SELECT MAX(ID) FROM Fish2"
                        cmd2.CommandText = "INSERT INTO Fish2(Name,Owner,Type,Gender,Descriptionn,ID) VALUES (@Name,@Owner,@Type,@Gender,@Description,@ID)"
                        cmd.Connection = con
                        cmd2.Connection = con
                        Dim MaxID As Integer
                        If Not IsDBNull(cmd.ExecuteScalar) Then
                            MaxID = cmd.ExecuteScalar()
                        Else
                            MaxID = 0
                        End If
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Name", SqlDbType.Text)).Value = TextBoxName.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Owner", SqlDbType.Text)).Value = TextBoxOwner.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Type", SqlDbType.Text)).Value = TextBoxType.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Gender", SqlDbType.Text)).Value = TextBoxGender.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Description", SqlDbType.Text)).Value = TextBoxDescription.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@ID", SqlDbType.Int)).Value = MaxID + 1
                        Dim fileName As String = (MaxID + 1).ToString & "." & strFileExt
                        FishUpload.PostedFile.SaveAs("\\RO0107116W1\Users\Public\Documents\Images\" + fileName)
                        Response.Redirect(Request.Url.AbsoluteUri)
                        cmd2.ExecuteNonQuery()
                        con.Dispose()
                    Else
                        ClientScript.RegisterStartupScript([GetType](), "message", "alert('41 KB size file is allowed');", True)
                    End If
                Else
                    ClientScript.RegisterStartupScript([GetType](), "message", "alert('Only jpg,.png,.gif files are allowed');", True)
                End If
            Else
                ClientScript.RegisterStartupScript([GetType](), "message", "alert('Please select a file');", True)
            End If
        End Sub
    
        Private Function GetData(query As String) As DataTable
            Dim dt As New DataTable()
            Dim constr As String = ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
            Using con As New SqlConnection(constr)
                Using cmd As New SqlCommand(query)
                    Using sda As New SqlDataAdapter()
                        cmd.CommandType = CommandType.Text
                        cmd.Connection = con
                        sda.SelectCommand = cmd
                        sda.Fill(dt)
                    End Using
                End Using
                Return dt
            End Using
        End Function
    
    End Class

    I also created a Fish2 table, mirror of Fish, and I replaced everything with Fish2, same problem.

    The part with MaxID works correctly because an image named 1.png is created in my folder on click so MaxID is 0.

    Tuesday, November 4, 2014 8:10 AM
  • User724169276 posted

    Thats because you are redirecting before executing the command.

     Response.Redirect(Request.Url.AbsoluteUri)
     cmd2.ExecuteNonQuery()

    See :

    Imports System.Data.SqlClient
    Imports System.Web.HttpContext
    Imports System.Data
    Imports System.Configuration
    Imports System.IO
    
    Partial Class _Aquarius
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            If Not Me.IsPostBack Then
                FishGridView.DataSource = GetData("SELECT Name,Owner,Type,Gender,Description,ID FROM Fish2")
                FishGridView.DataBind()
            End If
            If Not IsPostBack Then
                divAddFish.Visible = False
                SubmitStatus.Text = ""
            End If
        End Sub
    
        Public Sub ReturnChat_Click(sender As Object, e As EventArgs)
            Response.Redirect("Default.aspx")
        End Sub
    
        Public Sub AddFish_Click(sender As Object, e As EventArgs)
            divAddFish.Visible = True
            SubmitStatus.Text = ""
        End Sub
    
        Public Sub SubmitFish_Click(sender As Object, e As EventArgs)
            If FishUpload.HasFile Then
                divAddFish.Visible = False
                Dim imgLen As Integer = FishUpload.PostedFile.ContentLength
                Dim strFileExt As String = System.IO.Path.GetExtension(FishUpload.FileName).ToLower().Substring(1, 3)
                If strFileExt = "jpg" OrElse strFileExt = "png" OrElse strFileExt = "gif" Then
                    If imgLen <= 42151 Then
                        'Create the connection
                        Dim con As New SqlConnection()
                        con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString
                        con.Open()
                        Dim cmd As New SqlCommand()
                        Dim cmd2 As New SqlCommand()
                        cmd.CommandText = "SELECT MAX(ID) FROM Fish2"
                        cmd2.CommandText = "INSERT INTO Fish2(Name,Owner,Type,Gender,Descriptionn,ID) VALUES (@Name,@Owner,@Type,@Gender,@Description,@ID)"
                        cmd.Connection = con
                        cmd2.Connection = con
                        Dim MaxID As Integer
                        If Not IsDBNull(cmd.ExecuteScalar) Then
                            MaxID = cmd.ExecuteScalar()
                        Else
                            MaxID = 0
                        End If
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Name", SqlDbType.Text)).Value = TextBoxName.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Owner", SqlDbType.Text)).Value = TextBoxOwner.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Type", SqlDbType.Text)).Value = TextBoxType.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Gender", SqlDbType.Text)).Value = TextBoxGender.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@Description", SqlDbType.Text)).Value = TextBoxDescription.Text
                        cmd2.Parameters.Add(New SqlClient.SqlParameter("@ID", SqlDbType.Int)).Value = MaxID + 1
                        Dim fileName As String = (MaxID + 1).ToString & "." & strFileExt
                        FishUpload.PostedFile.SaveAs("\\RO0107116W1\Users\Public\Documents\Images\" + fileName)
                        cmd2.ExecuteNonQuery()                    
    con.Dispose(); Response.Redirect(Request.Url.AbsoluteUri) Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('41 KB size file is allowed');", True) End If Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('Only jpg,.png,.gif files are allowed');", True) End If Else ClientScript.RegisterStartupScript([GetType](), "message", "alert('Please select a file');", True) End If End Sub Private Function GetData(query As String) As DataTable Dim dt As New DataTable() Dim constr As String = ConfigurationManager.ConnectionStrings("SQLDbConnection").ConnectionString Using con As New SqlConnection(constr) Using cmd As New SqlCommand(query) Using sda As New SqlDataAdapter() cmd.CommandType = CommandType.Text cmd.Connection = con sda.SelectCommand = cmd sda.Fill(dt) End Using End Using Return dt End Using End Function End Class

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 4, 2014 8:47 AM
  • User724169276 posted

    Dear A2H,

    Please correct the code:

    Response.Redirect(Request.Url.AbsoluteUri)
    da.InsertCommand.ExecuteNonQuery()

    da.InsertCommand.ExecuteNonQuery()
    Response.Redirect(Request.Url.AbsoluteUri)

    Tuesday, November 4, 2014 8:50 AM
  • User2103319870 posted

    Dear A2H,

    Please correct the code:

    A2H

    Response.Redirect(Request.Url.AbsoluteUri)
    da.InsertCommand.ExecuteNonQuery()

    da.InsertCommand.ExecuteNonQuery()
    Response.Redirect(Request.Url.AbsoluteUri)

    Good Catch Ashim and Thanks for correcting my code

    Tuesday, November 4, 2014 9:18 AM
  • User724169276 posted

    Your welcome. Hope The OP problem is solved. :)

    Tuesday, November 4, 2014 9:20 AM
  • User1601006133 posted

    Thank you both!!!   It worked perfectly

    da.SelectCommand.ExecuteNonQuery()
    Response.Redirect(Request.Url.AbsoluteUri)

    Tuesday, November 4, 2014 9:50 AM