locked
Cannot Insert data into my Azure SQL Database via Webform page. RRS feed

  • Question

  • User129619948 posted

    Right, so I have an ASP webform and I have an Azure database. I use Visual Studio and I use SQL Server Manager. I just cannot seem to get any data I put into my HTML webform into my SQL Database, is there a reason as to why this won't do what I tell it to do? Or is this because whoever developed this software is a tad light in the skull?

    This is getting to be a joke now and I'm beginning to lose my patience, I use the training video below and it works for this instructor but not for me

    https://www.youtube.com/watch?v=POWm4EfU9bA

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    
    namespace xxxxxxn
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
           
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (Page.IsPostBack == true)
                {
                    Label1.Text = ("Great job!");
                    
                }
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                SqlConnection stormconn = new SqlConnection("Server=tcp:xxx.database.windows.net,1433;Initial Catalog=xxxxx;Persist Security Info=False;User ID=xxxx;Password=xxxxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");
                {
                    SqlCommand insert = new SqlCommand("InsertFullname", stormconn);
                    insert.CommandType = System.Data.CommandType.StoredProcedure;
                    insert.Parameters.AddWithValue("@Fullname", TextBox1.Text);
                    insert.Parameters.AddWithValue("@Address", TextBox2.Text);
                    insert.Parameters.AddWithValue("@Email", TextBox3.Text);
    
                    stormconn.Open();
                    insert.ExecuteNonQuery();
                    stormconn.Close();
    
                    if (IsPostBack)
                    {
                        TextBox1.Text = ("");
                    }
                }
            }
        }
    }



    Monday, February 4, 2019 1:20 PM

All replies

  • User283571144 posted

    Hi Blue City Capital,

    Blue City Capital

    I just cannot seem to get any data I put into my HTML webform into my SQL Database, is there a reason as to why this won't do what I tell it to do? Or is this because whoever developed this software is a tad light in the skull?

    According to your description and codes, I couldn't directly find out the reason why you couldn't get the data into sql database.

    I found your codes doesn't contains anything to select the value from database.

    I suggest you could try to follow below steps to find out the value you have insert into the azure sql database.

    1.Open the azure sql database protal and find  the Query editor.

    2. Add the select query in the query1.

    Like image shows:

    select * from employee

    Then it will show the insert value you have inserted into the sql database.

    If you could find the result you have inserted into the azure sql database.

    I suggest you could firstly tell me the error message and the details stored produced you have used in your azure sql database.

    Best Regards,

    Brando

     

    Tuesday, February 5, 2019 3:32 AM