hi
thanks for response..
By mistake marked as answered..
actually it works fine for recently processed file becoz of max(fileid) ..
a little enhancement what i need is to download recently processed along with file which are all processed some times back based on user need which file they wish to download..
want to show all files in db based on that files user may download the content of file what they want

Akshay PhadkePosted Mar 9, 2017, 2:47 AM
Shalu ShaliniPosted Mar 9, 2017, 4:59 AM
Akshay PhadkePosted Mar 9, 2017, 4:26 AM
Shalu ShaliniPosted Mar 9, 2017, 3:11 AM
Akshay PhadkePosted Mar 9, 2017, 1:46 AM
Shalu ShaliniPosted Mar 9, 2017, 1:44 AM
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace projectemailverifier
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sqlconstr = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(sqlconstr);
SqlCommand sqlcom = new SqlCommand("select * from PREVTXFILEUPLOAD where User_Id=@user_id");
using (SqlDataAdapter sqlda = new SqlDataAdapter())
{
sqlcom.CommandType = CommandType.Text;
sqlcom.Parameters.AddWithValue("@user_id", 1);
sqlcom.Connection = sqlcon;
sqlcon.Open();
DataTable dt = new DataTable("dt");
sqlda.SelectCommand = sqlcom;
sqlda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
sqlcon.Close();
}
}
protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && GridView1.EditIndex!=e.Row.RowIndex)
{
// e.Row.Cells[0].Text = Session["namefromsession"].ToString();
// Label lblEmail = (Label)e.Row.FindControl("lblfileid");
//lblEmail.Text = Session["emailfromsession"].ToString();
// Label lblEmail = (Label)e.Row.FindControl("lblfileid");
Session["fileid"] = (e.Row.Cells[0].FindControl("lblfileid") as Label).Text;
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string fileid = GridView1.SelectedRow.Cells[0].Text.ToString();
Session["fileid"] = fileid;
//Response.Redirect("~/EditCandidate.aspx");
}
//protected void fnfileid()
//{
// string constr = ConfigurationManager.ConnectionStrings["Sqlconn"].ConnectionString;
// SqlConnection sqlconn = new SqlConnection(constr);
// SqlCommand sqlcomm = new SqlCommand("Select * from prevtxfileupload where User_Id=@user_id");
// using (SqlDataAdapter sqlda = new SqlDataAdapter())
// {
// sqlcomm.CommandType = CommandType.Text;
// sqlcomm.Parameters.AddWithValue("@user_id", Session["User_Id"]);
// sqlcomm.Connection = sqlconn;
// sqlconn.Open();
// Session["fileid"] = sqlcomm.ExecuteScalar();
// sqlconn.Close();
// }
//}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace projectemailverifier
{
public partial class valid1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//fnfileid();
string constr = ConfigurationManager.ConnectionStrings["Sqlconn"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT distinct Valid_Ids FROM PREVTXUSERVALIDATEDEMAILIDS where User_Id=@user_id and Valid_Ids<>'Temp' and Id=@fid"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
cmd.Parameters.AddWithValue("@user_id", 1);
cmd.Parameters.AddWithValue("@fid", Session["fileid"]);
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
//Build the Text file data.
string txt = string.Empty;
//foreach (DataColumn column in dt.Columns)
//{
// //Add the Header row for Text file.
// txt += column.ColumnName + "\t\t";
//}
//Add new line.
//txt += "\r\n";
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
//Add the Data rows.
txt += row[column.ColumnName].ToString() + "\t\t";
}
//Add new line.
txt += "\r\n";
}
//Download the Text file.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=Valid_Export.txt");
Response.Charset = "";
Response.ContentType = "application/text";
Response.Output.Write(txt);
Response.Flush();
Response.End();
}
}
}
}
}
//protected void fnfileid()
//{
// string constr = ConfigurationManager.ConnectionStrings["Sqlconn"].ConnectionString;
// SqlConnection sqlconn = new SqlConnection(constr);
// SqlCommand sqlcomm = new SqlCommand("Select max(Id) from prevtxfileupload where User_Id=@user_id");
// using (SqlDataAdapter sqlda =new SqlDataAdapter())
// {
// sqlcomm.CommandType = CommandType.Text;
// sqlcomm.Parameters.AddWithValue("@user_id", Session["User_Id"]);
// sqlcomm.Connection = sqlconn;
// sqlconn.Open();
// Session["fileid"] = sqlcomm.ExecuteScalar();
// sqlconn.Close();
// }
//}
}
}
Shalu ShaliniPosted Mar 9, 2017, 1:39 AM
Akshay PhadkePosted Mar 9, 2017, 1:34 AM
Shalu ShaliniPosted Mar 9, 2017, 1:26 AM
Akshay PhadkePosted Mar 9, 2017, 1:18 AM
http://www.c-sharpcorner.com/article/upload-files-and-save-in-oracle-database-in-blob-format-in-asp-net/