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

How do I add code to redirect my user on successful submit to my database?

Any help would be really helpful.

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3. Partial Class CPD_OnlineSurvey
  4.     Inherits System.Web.UI.Page
  5.  
  6.     Public Sub UpdateOnlineSurvey(ByVal sender As Object, ByVal e As EventArgs)
  7.         Using conn As New SqlConnection()
  8.             conn.ConnectionString = ConfigurationManager _
  9.                         .ConnectionStrings("wincts").ConnectionString
  10.             Using cmd As New SqlCommand()
  11.                 cmd.CommandText = "update OnlineSurvey set IsSelected = " & _
  12.                                   "@IsSelected where QuestionId=@QuestionId"
  13.                 cmd.Connection = conn
  14.                 conn.Open()
  15.                 For Each item As ListItem In ChkOnlineSurvey.Items
  16.                     cmd.Parameters.Clear()
  17.                     cmd.Parameters.AddWithValue("@IsSelected", item.Selected)
  18.                     cmd.Parameters.AddWithValue("@QuestionId", item.Value)
  19.                     cmd.ExecuteNonQuery()
  20.                 Next
  21.                 conn.Close()
  22.             End Using
  23.         End Using
  24.     End Sub
  25. End Class
Apr 23 '10 #1
2 1037
semomaniz
210 Expert 100+
use a try catch block and then right after the next statement user Response.Redirect (" ").
Apr 23 '10 #2
Frinavale
9,735 Expert Mod 8TB
Dibblejon, in the future could you please ask the question in thread instead of just in the title the thread? It's a little confusing when there's no question and a bunch of code posted in the thread.

Anyways, semomaniz has made a great recommendation.
The ExecuteNonQuery Method will throw an exception if anything goes wrong...so that's one way to check if the data was successfully submitted. The ExecuteNonQuery method returns an Integer that specifies the number of rows affected by the query. If this number is 0 then you know that the update also didn't work....

-Frinny
Apr 23 '10 #3

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

Similar topics

4
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when...
13
by: Purple Haze | last post by:
ASP has <%Response.redirect("http://blahblah")%> What is the equivalent command in php to redirect a user to a new URL in the same window? Or is there a Javascript command that does this job...
5
by: Simon | last post by:
Hi, I have a Login.php page that logs the user in and out. I has two forms within the page, (depending on what we are trying to do), either one to log in or out. The form calls itself using a...
2
by: D. Nii | last post by:
Hi there, I have a web application that recently got redesigned and now makes use of Response.Redirect . The "new" application is hosted on Win2000 and works for all kinds of clients using IE...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a drop-down list, or input data into a text box. The user...
0
by: WebHouse.Co | last post by:
Hi Sir I'm in my 2nd year in M.Sc. degree & I made a project about the powerful tools SQLXML 3.0 & updategram, so I made a list of programs which r they so similar to the example that using...
10
by: GreggTB | last post by:
I've got an page (LOGIN.ASPX) that receives the user's login information. During the page load, it checks the credentials against a database and, if validation is successful, creates an instance of...
0
by: sathyakvani | last post by:
hi al i wrote a code (LOgin form) that checks the user id and if it exists validates the password but this is not all validating and simply displaying user does not exist i am sending the code...
1
by: roshina | last post by:
Hi Iam facing a problem in my project, developing a web site for online shopping in ASP on windows XP using IIS server. All the validations are ok but the new password is not upadated in the data...
12
by: backups2007 | last post by:
How do I submit form entries to the database and redirect to the same page, with the entries still display on the fields of the form? I really need help on this. Thanks.
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.