Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 4th, 2011, 01:43 PM
Authorized User
Join Date: Feb 2011
Posts: 37
Thanks: 8
Thanked 0 Times in 0 Posts
Default Insert statement?


Does anyone have any experience of SQL Insert Statement. I have the below statement in one of my ASP projects. The first time the user executes the statement it works as intended and creates one entry into the corresponding table, but if the same user attempts to insert another new record into the same table again it duplicates the insert entry and you end up with three entries all in all in that table for the specific user and so on? i.e.


Record 1


Record 2

Record 2 COPY


Record 3

Record 3 COPY

Record 3 COPY

Dim connection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("LiteratureCataloguingConnectionString").ConnectionString)
        Dim sql As String = "INSERT INTO Loan (PublicationID, UserId, StartLoanDate, EndLoanDate, ThirdDayNotification, FifthDayNotification, FifteenthDayNotification, ThirtiethDayNotification) VALUES (@PublicationID, @UserId, @StartLoanDate, @EndLoanDate, @ThirdDayNotification, @FifthDayNotification, @FifteenthDayNotification, @ThirtiethDayNotification)"

        Dim command As SqlCommand = New SqlCommand(sql, connection)
        command.Parameters.AddWithValue("@PublicationID", PublicationID)
        command.Parameters.AddWithValue("@UserId", UserId)
        command.Parameters.AddWithValue("@StartLoanDate", SDate)
        command.Parameters.AddWithValue("@EndLoanDate", FDate)
        command.Parameters.AddWithValue("@ThirdDayNotification", (0))
        command.Parameters.AddWithValue("@FifthDayNotification", (0))
        command.Parameters.AddWithValue("@FifteenthDayNotification", (0))
        command.Parameters.AddWithValue("@ThirtiethDayNotification", (0))

Reply With Quote
  #2 (permalink)  
Old May 5th, 2011, 02:53 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

Is this all the relevant code? I see no reason why this code would insert multiple records, so the problem is likely elsewhere...


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert statement Banishah ASP.NET 3.5 Basics 1 August 9th, 2009 01:51 PM
Autonumber and insert into statement. rupen Access VBA 1 July 27th, 2007 02:23 PM
Insert Statement Iashia06 Access 0 April 7th, 2006 12:45 PM
How do you execute a Insert statement? brendan82 Beginning VB 6 3 December 29th, 2003 12:26 PM

All times are GMT -4. The time now is 10:32 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.