SQL Database not working with ASP.NET web form

SQL Database not working with ASP.NET web form

By : Opapanoodee NooDee E
Date : November 21 2020, 04:01 AM
wish of those help If your creating a registration it would be like this. Change the names for these the way they are called in your database and for the other ones to. (@FirstName, @Surname, @Password, @Username,)
code :
   protected void Button1_Click(object sender, EventArgs e)

                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["YOUR_CONNECION_STRING_HERE"].ConnectionString);


                string insertQuery = "insert into Table1(FirstName, Surname, Username, Password) " +
                    "values(@FirstName, @Surname, @Password, @Username,)";
                SqlCommand com = new SqlCommand(insertQuery, conn);

                com.Parameters.AddWithValue("@FirstName", Textbox1.Text);
                com.Parameters.AddWithValue("@Surname", Textbox2.Text);
                com.Parameters.AddWithValue("@Password", Textbox3.Text);
                com.Parameters.AddWithValue("@Username", Textbox4.Text);

                //This actually executes the query with the given values above.



                Response.Write("there was a problem with your registration");

            catch (Exception problem)
                //throw Exception ;
                Response.Write("Error Message: " + problem.ToString());


Share : facebook icon twitter icon
Form submit capture into database not working

Form submit capture into database not working

By : dannypier
Date : March 29 2020, 07:55 AM
I wish did fix the issue. It will fail to capture this button press if someone hits "enter" to submit the form. If this is a data item, it would be better to capture it in a different way to be honest, as this only works when someone clicks the button or focusses the button before hitting enter.
Hitting enter to submit a form is default behaviour for browsers, albeit with a few variations based on form size and field type (for example, a textarea will not submit on enter, but an input type="text" will submit on enter).
INSERT INTO database table, from form not working. SQL

INSERT INTO database table, from form not working. SQL

By : user3431905
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Change the single quotes surrounding the table name and the column name to backticks. Or get rid of them all together.
code :
$sql="INSERT INTO `test` (`name`)  VALUES ('{$_POST['namefield']}')";
Form to input to sql database not working

Form to input to sql database not working

By : user3147830
Date : March 29 2020, 07:55 AM
seems to work fine Missing ); Use this...
mysqli_query($connect,"INSERT INTO test_table (id, name, surname) VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')");
HTML Form and PHP Script to insert into database not working

HTML Form and PHP Script to insert into database not working

By : Lorenzo Boffelli
Date : March 29 2020, 07:55 AM
will help you You need to add method="post" to your form..!
The reason all your conditions are failing is because $_POST is null. You aren't posting any data since the default form method is GET.
Form closes with an error when working with the database

Form closes with an error when working with the database

By : user3535825
Date : March 29 2020, 07:55 AM
around this issue You have a DB class which is good to separate you database code from your user interface code. I moved the database code to retrieve the Country data to the DB class. Notice how the DB class knows nothing about the user interface and the user interface knows nothing about the database.
Database objects need to be closed and disposed. using blocks take care of this for you even if there is an error.
code :
    public class DB
        private string ConStr = "Your connection string";

        public DataTable GetCountryData(string nC)
            DataTable dt = new DataTable();
            using (SqlConnection cn = new SqlConnection(ConStr))
            using (SqlCommand cmd = new SqlCommand("SELECT * FROM Voucher WHERE Name_Country= @nC", cn))
                cmd.Parameters.Add("@nC", SqlDbType.VarChar, 100).Value = nC;
            return dt;
    private void OpCode()
         if (comboBox1.SelectedIndex < 0)
            MessageBox.Show("Please select a value in the drop down.");
        DB DataClass = new DB();
        dataGridView1.DataSource = DataClass.GetCountryData(comboBox1.SelectedValue.ToString());
Related Posts Related Posts :
  • Allowing access to everyone to a particular page
  • How do I get attributes from a .NET assembly that's referenced by a web project?
  • .Net Core Web API with Client Certificate Authentication
  • Passing parameter to Web API with ajax
  • show a bootstrap modal on page load in asp.net
  • Storing user Data in Session ASP NET
  • running ASP.NET Core project from Visual Studio
  • ip4 address of server from asp.net HttpContext C#
  • ASP.NET 4.6 MVC Output Caching with Razor Syntax Issues
  • Visual Studio 2015 and IIS Express get ERR_CONNECTION_REFUSED
  • Regex to add space to string in asp.net
  • Regex extract string based on pattern
  • SignalR hub context from web app is not calling a client( console app) method
  • Validation of viewstate MAC failed Error on Azure Web App
  • ASP.Net and DotNetNuke -- why does a customer AuthorizeAttribute override ValidateAntiForgeryToken?
  • Dealing with a NullReferenceException after user is idle for over a certain amount of time
  • copy media files from one folder to another, but rename the files
  • Swagger Authorization Header not visible in ASP.NET Core project
  • In .net onblur event display message in label, is it possible
  • ASP.NET web.config Could not find the specified membership provider
  • Executing only the last function called
  • Linq to entities multiple WHERE clause &&
  • How to disable a drop down list with CSS, so it appears grayed out?
  • MVC Partials/Controls Requiring Data
  • Creating cookieless application on development machine with asp.net
  • asp.net - Hyperlink not working
  • how to open a new window on click event of node in ASP.Net TreeView control
  • ASP.NET MVC url search parameter without question mark
  • ASP.net Server.Transfer problem + Images are not getting
  • Disable form authentication for public pages
  • Is it possible to route a Webmethod?
  • Html control and asp.net web control
  • Is there any way in Linq To SQL to obtain the underlying (raw) SQL happening in a SubmitChanges() call?
  • page loads very slowly after its left idle
  • How to export current ASPX page to PDF
  • What is a Generic Handler in asp.net and its use?
  • Confused with asp.net controls and html controls
  • Are Active X for asp.net outdated? What other options do I have?
  • From asp.net code behind (aspx.cs) on the server how can I determine if Silverlight is installed on the client?
  • Is it possible to configure a location in Web.config to only allow local connections
  • How to set checked property of CheckBoxList items in aspx markup?
  • asp.net sessions lost when the page is reloaded (ispostback = false)
  • Request.QueryString[] does not return my desired value
  • ASP.NET Refrence to my local PC in users event log, why?
  • How to use a variable defined in code behind file in ASP.NET on inline code for the same page
  • Error: allowDefinition='MachineToApplication' beyond application level
  • ASP.NET Checkbox databinding to Byte datatype
  • Difference between axd and ashx handlers
  • Moving from WebForms to ASP.NET MVC
  • Cache the DTO or cache data from the expensive resource
  • Migrate Access to ASP.NET
  • Hyperlink in a Datalist
  • ASP.NET: Scheduled tasks
  • Is there a way to update a ViewModel in MVC2?
  • How to bind a function to "Click" event of a dynamically added ImageButton?
  • jQuery server side DOM manipulation
  • window.XMLHttpRequest is undefined in IE7/IE8
  • Detect whether the ie8 xss filter is enabled
  • I would like to convert Joomla CMS to ASP.net as there is no CMS like Joomla in .net. Would that be a good idea?
  • How Can I Use NUnit with ASP.NET Website (Not Web Project)?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org