statement inserts 2 DB records instead of 1

The below code demonstrates the way I am uploading a file to my webserver, and attempting to AFTER upload perform a simple INSERT statement into my SQL database table.  Now, this routine works good except for the fact I am getting (2) rows added to the database instead of just one.  The file DOES upload, and the INSERT does occur, just inserts 2 records instead of one.  What am I doing wrong?
Dim filepath As String = fileUpEx.PostedFile.FileName
        Dim pat As String = "\\(?:.+)\\(.+)\.(.+)"
        Dim r As Regex = New Regex(pat)
        Dim m As Match = r.Match(filepath)
        Dim file_ext As String = m.Groups(2).Captures(0).ToString()
        Dim filename As String = m.Groups(1).Captures(0).ToString()
        Dim file As String = filename & "." & file_ext
        fileUpEx.PostedFile.SaveAs(Server.MapPath("\productimages\") & file)
        lblStatus.Text = file
        Dim connect As SqlConnection = New SqlConnection
        connect.ConnectionString = "<MY CONNECTION>"
        Dim strSQLInsert As String
        strSQLInsert = "INSERT INTO Products_Images(ProductID,FileName) values ("
        strSQLInsert = strSQLInsert & "'" & Trim(Request.QueryString("ProductID")) & "',"
        strSQLInsert = strSQLInsert & "'" & Trim(file) & "')"
        Dim command1 As New SqlCommand(strSQLInsert, connect)
            connect = Nothing
        End Try

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ur function is being called twice .. it may be due to page post back

debug using bookmarks

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Whats the name of function where this code appears / is written?
chrisryhalAuthor Commented:
Its a button click
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

So just check whether  a button click on HTML side has something like OnClick event and on code side do you have something like Button1_Click  ..... Handles Event Name (where you have a button Click event written)?

If you both mentioned remove anyone of them while keeping the second one in-tact

Hope this helps you!

chrisryhal, is your problem solved?
please reply
chrisryhalAuthor Commented:
It was a little of both.  The onclick event was there and also the postback error so I split the points.  Thanks for the pointers
most welcome...!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.