473,385 Members | 1,320 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,385 software developers and data experts.

How do I pervent data posting twice from my form to the database.

1
Here is my code.(submit botton) whenever I refresh,the previous data posts back to the database.how do I prevent this please.Also,how do I prevent posting existing to database.
Expand|Select|Wrap|Line Numbers
  1.  Partial Class Contact
  2.     Inherits System.Web.UI.PageProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         Dim maluda As New SqlDataSource
  4.         With maluda
  5.             .ConnectionString = ConfigurationManager.ConnectionStrings("unique2").ConnectionString
  6.             .InsertCommandType = SqlDataSourceCommandType.Text
  7.             .InsertCommand = "insert into dbcontact(Fname,Email,Phone,Gender,State,Subject,Msg,Cdate) values (@Fname,@Email,@Phone,@Gender,@State,@Subject,@Msg,@Cdate)"
  8.             .InsertParameters.Add("Fname", txtfname.Text)
  9.             .InsertParameters.Add("Email", txtemail.Text)
  10.             .InsertParameters.Add("Phone", txtPN.Text)
  11.             .InsertParameters.Add("Gender", txtgender.SelectedItem.ToString)
  12.             .InsertParameters.Add("State", txtstate.SelectedItem.ToString)
  13.             .InsertParameters.Add("Subject", txtsubject.Text)
  14.             .InsertParameters.Add("Msg", txtmsg.Text)
  15.             .InsertParameters.Add("Cdate", Date.Today)
  16.  
  17.         End With
  18.         Dim luda As String
  19.         luda = maluda.Insert()
  20.  
  21.         'lblsucess.Text = "Delivered"
  22.         UserMsgBox(sMsg:="Msg sent...click ok to continue")
  23.  
  24.         txtfname.Text = ""
  25.         txtemail.Text = ""
  26.         txtPN.Text = ""
  27.         txtsubject.Text = ""
  28.         txtmsg.Text = ""
  29.  End Sub
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.     Public Sub UserMsgBox(ByVal sMsg As String)
  37.  
  38.         Dim sb As New StringBuilder()
  39.         Dim oFormObject As System.Web.UI.Control
  40.  
  41.         sMsg = sMsg.Replace("'", "\'")
  42.         sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
  43.         sMsg = sMsg.Replace(vbCrLf, "\n")
  44.         sMsg = "<script language=javascript>alert(""" & sMsg & """)</script>"
  45.  
  46.         sb = New StringBuilder()
  47.         sb.Append(sMsg)
  48.  
  49.         For Each oFormObject In Me.Controls
  50.             If TypeOf oFormObject Is HtmlForm Then
  51.                 Exit For
  52.             End If
  53.         Next
  54.  
  55.  
  56.         oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
  57.  
  58.     End Sub
Apr 12 '15 #1
0 1581

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have...
9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
1
by: Jim Heimer | last post by:
How can I pass data from one child form to another? I have two forms, one (formX) that holds a datagrid (with the results of a query) and another (formY) that consists of many textboxes. I'd like...
2
by: steve | last post by:
Hi All I need to learn how to update a SQl server or Access database located on a web server from my windows forms application, via the internet I have a customer who wants to run several...
6
by: punitshrivastava | last post by:
Hi all, I am Punit I am working in php .i want to delete records from database from php form . For this i code the code is: <?php $name = $_POST; $host="localhost"; // Host name ...
2
by: chamali | last post by:
Hi guys, I have created database using ms access & i have ceated a form using vb.net. i want to do this. when i enter the data to the form & after that click Submit button the data must be enter...
5
by: Mapi | last post by:
I need help. I am new to MS Access and have been assign this project. I want to be able to filter data from a form that will be displayed on a subform. I don't know if this is possible but...
2
by: John York | last post by:
I setup an online Access database and created a online data submission form using FrontPage 2003 to send data to the Access database. Works great for Windows users and some Mac computer users....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.