table value:-
album_name Genre_name artist price
legacy rock adam 110.00
never can say good bye jazz david 290.00
in this i want download only particular column of (album_name)...
Plz help me to solve this...
Class file:-
public class download
{
public download()
{
}
public static DataSet GetresourcePath()
{
SqlConnection con = new SqlConnection("Data Source=PRABAKARAN\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True");
con.Open();
string sql = "select album_name from addcart";
SqlCommand command = new SqlCommand(sql, con);
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "filePath");
return dataSet;
}
}
default page:-
try
{
DataSet path = download.GetresourcePath();
string filePath = "C:\\Users\\prabakarans\\Downloads\\Albums";
string fileName = path.ToString();
Stream stream = null;
stream = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
long bytesToRead = stream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-Disposition", "attachment; filename=" + fileName);
while (bytesToRead > 0)
{
if (Response.IsClientConnected)
{
byte[] buffer = new Byte[10000];
int length = stream.Read(buffer, 0, 10000);
Response.OutputStream.Write(buffer, 0, length);
Response.Flush();
bytesToRead = bytesToRead - length;
}
else
{
bytesToRead = -1;
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
when am executing a program
in this line....
stream = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
the error has showing access is denied..