Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
AnswerRe: problem writing in doc file Pin
Ennis Ray Lynch, Jr.21-Jul-10 5:38
Ennis Ray Lynch, Jr.21-Jul-10 5:38 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 5:48
Dhyanga21-Jul-10 5:48 
AnswerRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 5:39
mveOriginalGriff21-Jul-10 5:39 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 5:42
Dhyanga21-Jul-10 5:42 
GeneralRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 5:51
mveOriginalGriff21-Jul-10 5:51 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 5:54
Dhyanga21-Jul-10 5:54 
GeneralRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 6:03
mveOriginalGriff21-Jul-10 6:03 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 6:09
Dhyanga21-Jul-10 6:09 
protected void filetesting()
        {
           
            SqlConnection cnx = new SqlConnection(categories.strCnx);
            cnx.Open();
            string query = @"select * from categories";
            SqlCommand cmd = cnx.CreateCommand();
            cmd.CommandText = query;
            SqlDataReader dr;
            HttpContext.Current.Response.Clear(); //clear anything in io buffer
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=categories.doc");
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.ContentType = "application/vnd.ms-document";
            HttpContext.Current.Response.Write("categories" + '\n');


            try
            {
                i = 0;   
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    HttpContext.Current.Response.Write( dr[0].ToString());
                    
                    i++;
                    
                }
              
             
                for (int j = 0; j < i; j++)
                {
                    temp += s[j]+ '\n';
                }
                 HttpContext.Current.Response.End();
             
              
            }
            catch(Exception ex)
            {
                string pt = ex.ToString();
             
            }
          
        }


This works fine when i put the "HttpContext.Current.Response.End()" before the for loop but I want to run it after for loop. I want to execute "HttpContext.Current.Response.Write" command inside the for loop. But since it wasn't running, I kept it inside the while(dr.read()) code. But i really want to have "HttpContext.Current.Response.Write" inside the for loop.
suchita

GeneralRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 8:54
mveOriginalGriff21-Jul-10 8:54 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 9:44
Dhyanga21-Jul-10 9:44 
GeneralRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 9:51
mveOriginalGriff21-Jul-10 9:51 
GeneralRe: problem writing in doc file Pin
Dhyanga21-Jul-10 10:10
Dhyanga21-Jul-10 10:10 
GeneralRe: problem writing in doc file Pin
OriginalGriff21-Jul-10 21:55
mveOriginalGriff21-Jul-10 21:55 
GeneralRe: problem writing in doc file Pin
Dhyanga22-Jul-10 3:00
Dhyanga22-Jul-10 3:00 
GeneralRe: problem writing in doc file Pin
OriginalGriff22-Jul-10 3:49
mveOriginalGriff22-Jul-10 3:49 
GeneralRe: problem writing in doc file Pin
Dhyanga22-Jul-10 4:14
Dhyanga22-Jul-10 4:14 
GeneralRe: problem writing in doc file [modified] Pin
Dhyanga22-Jul-10 4:17
Dhyanga22-Jul-10 4:17 
QuestionLine on open/close brackets Pin
Blubbo21-Jul-10 4:26
Blubbo21-Jul-10 4:26 
AnswerRe: Line on open/close brackets Pin
Ennis Ray Lynch, Jr.21-Jul-10 4:36
Ennis Ray Lynch, Jr.21-Jul-10 4:36 
AnswerRe: Line on open/close brackets Pin
OriginalGriff21-Jul-10 4:56
mveOriginalGriff21-Jul-10 4:56 
AnswerRe: Line on open/close brackets Pin
PIEBALDconsult21-Jul-10 18:22
mvePIEBALDconsult21-Jul-10 18:22 
Questionconvert date question Pin
Jassim Rahma21-Jul-10 3:36
Jassim Rahma21-Jul-10 3:36 
AnswerRe: convert date question Pin
OriginalGriff21-Jul-10 3:46
mveOriginalGriff21-Jul-10 3:46 
AnswerRe: convert date question Pin
Luc Pattyn21-Jul-10 3:47
sitebuilderLuc Pattyn21-Jul-10 3:47 
Questionhow to open www.google.com and insert any text to the textbox search (only for show) Pin
Gali197821-Jul-10 3:32
Gali197821-Jul-10 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.