locked
Data Overlapping SQL Server Views RRS feed

  • Question

  • User-1297219282 posted

    I have made a website using asp.net web forms, through website I am storing data in SQL server, having multiple tables in database, they all are joined and created as a view having relationships also. The problem is when the data is entered through web forms it gets stored at last page but in case if I close the browser in the middle then the data in SQL server(in views) starts overlapping it picks up the previous data on first page where the browser was closed. I have tried using sessions but it doesn't work.

    Any help will be appreciated.

    Friday, October 25, 2019 6:44 PM

All replies

  • User409696431 posted

    Please expand on the description of your problem.  What do you mean by "it gets stored at last page", and "starts overlapping it picks up previous data on first page"?  "Close the browser in the middle" ... in the middle of what?   What did you think session would do to help an SQL data storage problem?

    Friday, October 25, 2019 6:56 PM
  • User-1297219282 posted

    I have 8 webforms where the user enters the data and on each page, the user data get stored in different tables in sql server and all the tables are then combined as view having the  relationships. The data is getting stored acurately in each table and in the view also but when i close the browser in middle then where the browser was closed it catches the previous data on first page. I am not sure if it has something with sessions or sql join.  

    Friday, October 25, 2019 7:04 PM
  • User409696431 posted

    I'm still not quite sure what you mean.  "When I close the browser in the middle" - Do you mean you only go through some of the pages, not all 8?

    And: "where the browser was closed it catches the previous data on first page."  What do you mean by "catches"?  If you are storing data on each of the 8 pages, and you close, for example page 6 without saving it, then the data for pages 1 - 5 will already have been saved, of course.  Is that what you mean?  That would be expected behavior.

    Or did you mean something else?

    Saturday, October 26, 2019 12:04 AM
  • User-258456925 posted

    Please try to share some code so we get better idea of your problem. Without looking at your code it's difficult to understand or troubleshoot your issue.

    Saturday, October 26, 2019 3:22 AM
  • User-1297219282 posted

    Yes. when I am  storing data on each of the 8 pages, and close, for example page 6 without saving it, then the data for pages 1 - 5 will already have been saved that is working. Each page data is stored in different tables and then all are combined in one table(view), when data is entered from page 1 to all the way last page 8 it goes properly in the combined table(view) for each customer but if i close browser in between then the data in all tables is going but when it comes to combination table(view) then itpicks up the value where it was closed and all the data in combination table(views) is not accurate. I dont know what exactly the problem is I am attaching my codes also.  

    Monday, October 28, 2019 7:53 PM
  • User-1297219282 posted

    This is for 1ST PAGE :

    SqlConnection con = new SqlConnection(…)

    con.Open();

    string save = "INSERT INTO ReporterData(Reporter,Ondutyone,Ondutytwo) VALUES (@Reporter,@Ondutyone,@Ondutytwo)";
    SqlCommand cmd = new SqlCommand(save, con);


    cmd.Parameters.AddWithValue("@Reporter", DropDownList7.SelectedItem.Value);
    cmd.Parameters.AddWithValue("@Ondutyone", DropDownList8.SelectedItem.Value);
    cmd.Parameters.AddWithValue("@Ondutytwo", DropDownList9.SelectedItem.Value);

    cmd.ExecuteNonQuery();
    con.Close();

    {

    Session["reporter"] = DropDownList7.SelectedItem.Value;

    }
    Server.Transfer("Student.aspx");

    2nd Page :
    {
    Label18.Text = Session["reporter"].ToString();

    }


    SqlConnection con = new SqlConnection(...);

    con.Open();

    string save = "INSERT INTO Studentdata(Student,Phase,Typeofabsence) VALUES (@Student,@Phase,@Typeofabsence)";
    SqlCommand cmd = new SqlCommand(save, con);

    cmd.Parameters.AddWithValue("@Student", DropDownList4.SelectedItem.Value);
    cmd.Parameters.AddWithValue("@Phase", RadioButtonList1.SelectedItem.Value);
    cmd.Parameters.AddWithValue("@Typeofabsence", RadioButtonList2.SelectedItem.Value);

    cmd.ExecuteNonQuery();
    con.Close();

    {

    Session["name"] = DropDownList4.SelectedItem.Value;


    }

    Last Page : 

    {
    Label5.Text = Session["reporter"].ToString();
    Label6.Text = Session["reporter"].ToString();

    }

    {

    TextBox2.Text = DateTime.Now.ToShortDateString();
    TextBox3.Text = DateTime.Now.ToShortTimeString();
    }
    }

    string save = "INSERT INTO Narrative(Narrative,Date,Time) VALUES (@Narrative,@Date,@Time)";
    SqlCommand cmd = new SqlCommand(save, con);
    cmd.Parameters.AddWithValue("@Narrative", TextBox1.Text);
    cmd.Parameters.AddWithValue("@Date", TextBox2.Text);
    cmd.Parameters.AddWithValue("@Time", TextBox3.Text);
    cmd.ExecuteNonQuery();

    {

    Session.Remove("name");
    Session.Remove("reporter");

    }

    Now I want to combine all the data in different tables into 1 table so that if the browser closes in between from any reason . The data entering should start from page 1 and go together in 1row.

    Monday, October 28, 2019 7:59 PM
  • User288213138 posted

    Hi shubh5506,

    Each page data is stored in different tables and then all are combined in one table(view), when data is entered from page 1 to all the way last page 8 it goes properly in the combined table(view) for each customer but if i close browser in between then the data in all tables is going but when it comes to combination table(view) then itpicks up the value where it was closed and all the data in combination table(views) is not accurate

    According to your posted code, I can't reproduce your question.

    In your code, You just redirect one page to another and pass the value of the session.

    Can you show me how did you combine different tables in one table?

    So please post the code that can reproduce your question.

    Best regards,

    Sam

    Tuesday, October 29, 2019 8:40 AM