Click here to Skip to main content
15,922,407 members
Home / Discussions / C#
   

C#

 
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 
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 
It is showing the error is at line
s[i] = dr[0].ToString();
. The code
HttpContext.Current.Response.Write("HELP!\n");
also not working. Well I am using '\n' tab for new line. If i put "\n" , it will just print as "\n" and so i tried 'HELP!\n', which also didn't work. The code i was using is shown below :

protected void filetesting()
        {
           
            SqlConnection cnx = new SqlConnection(categories.strCnx);
          
            string query = @"select i.Name,i.Type,j.Item,j.ItemDescription from categories i, items j where i.ID = j.ID";
            
            SqlCommand objCmd = new SqlCommand(query, cnx);
            SqlDataAdapter objDA = new SqlDataAdapter(objCmd);
            
            
           
            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";
            SqlDataReader dr;
      
            cnx.Open();
            SqlCommand cmd = cnx.CreateCommand();
            cmd.CommandText = query;
            try
            {
                i = 0;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    s[i] = dr[0].ToString();

                    i++;

                }

                for (int j = 0; j < i; j++)
                {
                    if (s[j] == null)
                    {
                        HttpContext.Current.Response.Write("HELP!\n");
                    }
                    else
                    {
                        HttpContext.Current.Response.Write(s[j] + '\n');
                    }
                }
                HttpContext.Current.Response.End();

                // HttpContext.Current.Response.Write(s[0].ToString());

            }
            catch (Exception ex)
            {
                string pt = ex.ToString();

            }
            finally
            { HttpContext.Current.Response.End(); }
          
        }


Is there any other way to show the user formatted data in word document. Well if grab all my requirements in datagrid, how do I show them in word document. I guess the way I'm using is not correct..thats why I am getting these problems.
suchita

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 
AnswerRe: how to open www.google.com and insert any text to the textbox search (only for show) Pin
Luc Pattyn21-Jul-10 3:46
sitebuilderLuc Pattyn21-Jul-10 3:46 
GeneralRe: how to open www.google.com and insert any text to the textbox search (only for show) Pin
Jason Vetter21-Jul-10 4:31
Jason Vetter21-Jul-10 4:31 
QuestionRegex Problem,Extracting text from Table Pin
NaveenHS21-Jul-10 2:03
NaveenHS21-Jul-10 2:03 
AnswerRe: Regex Problem,Extracting text from Table Pin
Luc Pattyn21-Jul-10 2:13
sitebuilderLuc Pattyn21-Jul-10 2:13 
QuestionFunction Call Mechanism Pin
califax2k20-Jul-10 23:15
califax2k20-Jul-10 23:15 
AnswerRe: Function Call Mechanism Pin
PIEBALDconsult21-Jul-10 2:37
mvePIEBALDconsult21-Jul-10 2:37 

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.