473,513 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit Button (to SQL Server DB) Not working

294 Contributor
I have a submit button, where users are clicking after entering text into textboxes and (hopefully) check boxes (for yes/no).

Here is my code, and when I run it and press submit, there is no action. It just continues to loop. Any ideas why?

Expand|Select|Wrap|Line Numbers
  1.  string ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True";
  2.  
  3.             using (SqlConnection dataConnection = new SqlConnection(ConnectionString))
  4.             {
  5.                 using (SqlCommand dataCommand = dataConnection.CreateCommand())
  6.                 {
  7.                     dataCommand.CommandText = "INSERT INTO Review_Tbl (course_num, courseName, courseDesc, numQuiz, courseRating, txtBook, txtGrade) " + "VALUES(@CourseNumtxt, @CourseNametxt, @CourseDesctxt, @Quiztxt, @Ratingtxt, @txtBook, @txtGrade)";
  8.  
  9.                     dataCommand.Parameters.AddWithValue("@CourseNumtxt", CourseNumtxt.Text);
  10.                     dataCommand.Parameters.AddWithValue("@CourseNametxt", CourseNametxt.Text);
  11.                     dataCommand.Parameters.AddWithValue("@CourseDesctxt", CourseDesctxt.Text);
  12.                     //dataCommand.Parameters.AddWithValue("@MandatoryCbx", MandatoryCbx.Checked);
  13.                     //dataCommand.Parameters.AddWithValue("@AttendanceCbx", AttendanceCbx.Checked);
  14.                     dataCommand.Parameters.AddWithValue("@Quiztxt", Quiztxt.Text);
  15.                     //dataCommand.Parameters.AddWithValue("@RepeatCbx", RepeatCbx.Checked);
  16.                     dataCommand.Parameters.AddWithValue("@Ratingtxt", Ratingtxt.Text);
  17.                     dataCommand.Parameters.AddWithValue("@txtBook", txtBook.Text);
  18.                     dataCommand.Parameters.AddWithValue("@txtGrade", txtGrade.Text);
  19.  
  20.                     dataConnection.Open();
  21.                     dataCommand.ExecuteNonQuery();
  22.                     dataConnection.Close();
  23.  
Note: I took out the Checkboxes in the code to hopefully get a successful run, to no avail.
Nov 26 '13 #1
3 1341
Frinavale
9,735 Recognized Expert Moderator Expert
I don't see a loop?
Are you sure there is a continuous loop?
Or perhaps your connection string is incorrect and you haven't waited long enough for the database to time out?

-Frinny
Dec 2 '13 #2
mcupito
294 Contributor
I found the error. It was actually mismatches in naming between my sql statement and my database.

The loop I was referring to was actually "Waiting for localhost".. aka what I was entering was never truly being submitted.
Dec 2 '13 #3
Frinavale
9,735 Recognized Expert Moderator Expert
I'm glad you solved it :)
Dec 2 '13 #4

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

Similar topics

15
2526
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
2
12481
by: Hongyu | last post by:
I am trying to implement a simple JavaScript of redirecting my window to a new URL upon clicking a submit button. This is an easy task except when I have to put an input type='submit' in front of...
4
5571
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
2
1534
by: jbhan | last post by:
Hi, I have encountered a strange problem with an asp.net application. I have the same code deployed on staging and production. On clicking the submit button the app is supposed to send an email....
2
1968
by: martyn_wynne | last post by:
Hi, I have found a odd one, my submit button is not submitting on a method="get" form after using any form of DataBind? Has anyone struck this problem before? here is snipits of the code as...
2
3787
by: AnandaSim | last post by:
Hi All, A really puzzling phenomenon. I develop to a Windows 2000 development server in VS 2003. I use Copy Project to deploy the project to a production server. The webpage I'm having...
1
365
by: jim whitaker | last post by:
I followed this tutorial, and I have it working. http://www.webpasties.com/xmlHttpRequest/ My question is this: After an AJAX form receives it's data from the server, how could i then submit...
7
2057
by: Bjorn Sagbakken | last post by:
Hello. There maybe an simple answer to this, but sometimes one get a strange blindness when working intensely on one single problem. I'm using ASP.NET 2003, building pages that include 3 user...
5
1737
by: soheir | last post by:
am doing my first project so plz help i've created a submit button <input type="submit" onclick="valid()"> my function valid checks if the fields are not empty if empty a window prmpt appears...
1
3246
by: mukeshrasm | last post by:
Hi I am having problem like I have four forms which displayed when a tab is clicked. for all these forms initially I made style.display="none" inside div tag and then javascript function is used on...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.