473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Data inserting twice to DB

Can anybody tell me what i'm doing wrong?
The data is inserting 2 records at a time!!!
Thanks

Dim conn As SqlConnection
Dim cmdcommand As SqlCommand
Dim param As SqlParameter
Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

conn = New
SqlConnection("server=(local);database=Wintergreen ;integrated
security=true;")
conn.Open()
txtuser.ID = Request.ServerVariables("LOGON_USER")

cmdcommand = New SqlCommand("rote", conn)
cmdcommand.CommandType = CommandType.StoredProcedure

param = cmdcommand.Parameters.Add("ReturnValue", SqlDbType.Int)

param.Direction = ParameterDirection.ReturnValue
cmdcommand.Parameters.Add("@username", txtuser.Name)
cmdcommand.ExecuteNonQuery()

Label1.Text = "Thanks for filling Crazy John's Survey!"

conn.Close()

End Sub

Sprocedure
-----------
CREATE PROCEDURE rote
(@username varchar(50))
AS
INSERT INTO survey
(username,DateCreated)
VALUES (@username,getdate())
GO
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
1 1255
I think its the Post Back Event that do double insertion.
So in
Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load if Not (Page.PostBack) then
//write the insertion here
end if
"Patrick Olurotimi Ige" <ig*@iprimus.com.au> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl... Can anybody tell me what i'm doing wrong?
The data is inserting 2 records at a time!!!
Thanks

Dim conn As SqlConnection
Dim cmdcommand As SqlCommand
Dim param As SqlParameter
Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

conn = New
SqlConnection("server=(local);database=Wintergreen ;integrated
security=true;")
conn.Open()
txtuser.ID = Request.ServerVariables("LOGON_USER")

cmdcommand = New SqlCommand("rote", conn)
cmdcommand.CommandType = CommandType.StoredProcedure

param = cmdcommand.Parameters.Add("ReturnValue", SqlDbType.Int)

param.Direction = ParameterDirection.ReturnValue
cmdcommand.Parameters.Add("@username", txtuser.Name)
cmdcommand.ExecuteNonQuery()

Label1.Text = "Thanks for filling Crazy John's Survey!"

conn.Close()

End Sub

Sprocedure
-----------
CREATE PROCEDURE rote
(@username varchar(50))
AS
INSERT INTO survey
(username,DateCreated)
VALUES (@username,getdate())
GO
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL database. What would be a low-cost method I...
3
by: mg | last post by:
In the click event handler of an imagebutton (WebForm), my C# code gets the values in some textboxes and insert these values into database tables The page reloads itself after this event and the...
7
by: cover | last post by:
I have a form that writes to an MySQL database just fine but would like to email people to give them a heads up that an entry was made under their name (1 of 6 names on writing to the database). ...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
10
by: Szabolcs Horvát | last post by:
Consider the attached example program: an object of type 'A' is inserted into a 'map<int, Am;'. Why does 'm;' call the copy constructor of 'A' twice in addition to a constructor call? The...
1
by: cvschie | last post by:
Hi, I have a LED Sign with standard software to control messages (via serial port). Because the limitations of the software I want my own VB.net program. With a serial analyzer program, I see...
2
by: subramanian100in | last post by:
Is my following understanding correct ? Data abstraction means providing the interface - that is, the set of functions that can be called by the user of a class. Information hiding means...
10
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.