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

automatically all sessions are removed ....

Hi.

Problem is that all sessions are removed when I am using this code...
By this code I am deleting files in a particular folder and then that folder..

Need help......

code is:

Expand|Select|Wrap|Line Numbers
  1.  try
  2.         {
  3.             string str;
  4.  
  5.             string username = (string)Session["username"];
  6.             MySql.Data.MySqlClient.MySqlConnection oConn = new MySql.Data.MySqlClient.MySqlConnection(WebConfigurationManager.ConnectionStrings["filesystem"].ConnectionString);
  7.  
  8.             oConn.Open();
  9.  
  10.             MySql.Data.MySqlClient.MySqlCommand command =
  11.                         new MySql.Data.MySqlClient.MySqlCommand("select * from usefiles where USERNAME=?user;", oConn);
  12.  
  13.             command.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("?user", MySql.Data.MySqlClient.MySqlDbType.VarChar, 500));
  14.             command.Parameters[0].Value = (string)DropDownList1.SelectedValue;
  15.             MySqlDataReader dr = command.ExecuteReader();
  16.  
  17.             while (dr.Read())
  18.             {
  19.                 string serialnumber = (string)dr["FILENAME"];
  20.  
  21.                 System.IO.File.Delete(Server.MapPath(".") + "\\USERFOLDERS\\" + DropDownList1.SelectedValue + "\\" + serialnumber);
  22.  
  23.             }
  24.             oConn.Close();
  25.  
  26.  
  27.  
  28.             //if (str.Equals("yes"))
  29.             //{
  30.  
  31.             MySql.Data.MySqlClient.MySqlConnection oConn1 = new MySql.Data.MySqlClient.MySqlConnection(WebConfigurationManager.ConnectionStrings["filesystem"].ConnectionString);
  32.  
  33.             oConn1.Open();
  34.  
  35.  
  36.             MySql.Data.MySqlClient.MySqlCommand command1 =
  37.                 new MySql.Data.MySqlClient.MySqlCommand("delete from login where USERNAME=?user;", oConn1);
  38.             command1.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("?user", MySql.Data.MySqlClient.MySqlDbType.VarChar, 500));
  39.             command1.Parameters[0].Value = (string)DropDownList1.SelectedValue;
  40.  
  41.             command1.ExecuteNonQuery();
  42.             oConn1.Close();
  43.  
  44.  
  45.             oConn1.Open();
  46.             MySql.Data.MySqlClient.MySqlCommand command2 =
  47.                new MySql.Data.MySqlClient.MySqlCommand("delete from usefiles where USERNAME=?user;", oConn1);
  48.             command2.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("?user", MySql.Data.MySqlClient.MySqlDbType.VarChar, 500));
  49.             command2.Parameters[0].Value = (string)DropDownList1.SelectedValue;
  50.  
  51.             command2.ExecuteNonQuery();
  52.             oConn1.Close();
  53.             System.IO.Directory.Delete(Server.MapPath(".") + "\\USERFOLDERS\\" + DropDownList1.SelectedValue);
  54.  
  55.             // "Delete" the row 
  56.             //DeleteResults.Text += string.Format( "This would have deleted ProductID {0}<br />", productID);
  57.  
  58.             GridView1.DataBind();
  59.  
  60.             DropDownList1.Items.Clear();
  61.             DropDownList1.DataBind();
  62.            string a = "a";
  63.             Session["status"] = a;
  64.             Label4.Text = (string)Session["status"];
  65.             Panel1.Visible = false;
  66.  
  67.         }
  68.         catch (Exception exc)
  69.         {
  70.             Response.Write("<script tyep='text/javascript'>alert('Button2_Click<br/>" + exc.Message + "');</script>");
  71.         }
Jul 19 '08 #1
1 1067
kenobewan
4,871 Expert 4TB
Its good that you used a try catch block. Its bad that you didn't use a few. Try more debugging and report back. Thanks.
Jul 20 '08 #2

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

Similar topics

5
by: Jennifer Smith | last post by:
We have an environment running ASP on IIS5, where a user logs in via an ASP login page and an entry is made to the database recording the users login time and a database session. If the user then...
1
by: Dan | last post by:
Hi, I have a requirement where in I need to automatically fill a web form and trigger events on the web form automatically. Firstly can this be done. For example: I have a site say xyz.com which...
9
by: Laurent Bugnion | last post by:
Hi, I am wondering what is the best way to find out which ASP.NET sessions are still active. Here is the reason: I have a custom control which can upload files. It saves the files in a folder...
2
by: lovecreatesbeauty | last post by:
I'm disturbed on this question on a long time. I think if I finally get understand it with your kind help, I will get close to a excellent C++ programmer. And I only can rely on your expertise and...
0
by: Henrik Erlandsson | last post by:
I am using cookieless sessions. The problem is that I have an adapted version which is supposed to store the FormsAuthenticationTicket in a cache. I would prefer the session cache but it is not...
15
by: Mark Rae | last post by:
Hi, I'm presently converting a v1.1 ASP.NET app to v2, and am encountering a strange problem. When running in Debug mode (i.e. hitting F5), all is well. However, when running without...
3
by: Harolds | last post by:
We are currently converting our web site for asp.net 1.1 to asp.net 2.0. We use cookieless sessions. We have discovered a problem, when someone using a bookmark set from when the site was 1.1 they...
4
by: ctclibby | last post by:
Hi All Seem to be getting zombie sessions. /tmp/sess_ exist and are owned by daemon. I am guessing and these could come from brower crashes, networks gone down ... etc ... even from stuff that...
7
by: PI | last post by:
Hi Guys, I need some with this please. I have a bit of code which stores user selections within a cart and persists the cart using sessions. The user may at any time click a button to view the...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.