I made some changes in the Code to stop dublicating an email and Label in the same page.
Try it with Ajax its great!
----------Code-------------
Protected Sub Submitbottom_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submitbottom.Click
Dim dtbsourceemail As New SqlDataSource()
dtbsourceemail.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnection" ).ToString()
Dim con As New System.Data.SqlClient.SqlConnection(System.Configuration.Co nfigurationManager.ConnectionStrings.Item("DatabaseConnecti on").ConnectionString)
Dim adp As New System.Data.SqlClient.SqlDataAdapter("select * from Email where EmailAddress='" & EmailAddresstextbox.Text & "'", con)
Dim dt As New System.Data.DataTable
adp.Fill(dt)
If dt.Rows.Count = 0 Then
dtbsourceemail.InsertCommandType = SqlDataSourceCommandType.Text
dtbsourceemail.InsertCommand = "INSERT INTO Email (EmailAddress , IPAddress, DateTimeStamp) VALUES (@EmailAddress, @IPAddress, @DateTimeStamp)"
dtbsourceemail.InsertParameters.Add("EmailAddress", EmailAddresstextbox.Text)
dtbsourceemail.InsertParameters.Add("IPAddress", Request.UserHostAddress.ToString)
dtbsourceemail.InsertParameters.Add("DateTimeStamp", DateTime.Now())
Dim rowsAffected As Integer = 0
Try
rowsAffected = dtbsourceemail.Insert()
Catch ex As Exception
Label.Text = "Problem with adding"
Finally
dtbsourceemail = Nothing
End Try
If rowsAffected <> 1 Then
Label.Text = "Problem with adding"
Else
Label.Text = "Thank you for joining our Mailing list"
End If
Else
Label.Text = "Email Already Exist"
End If
End Sub