Click here to Skip to main content
15,903,175 members
Home / Discussions / C#
   

C#

 
GeneralProblem in creating objects of derived class Pin
tttyip12-Jul-05 20:28
tttyip12-Jul-05 20:28 
GeneralRe: Problem in creating objects of derived class Pin
S. Senthil Kumar12-Jul-05 21:15
S. Senthil Kumar12-Jul-05 21:15 
GeneralRe: Problem in creating objects of derived class Pin
tttyip13-Jul-05 16:11
tttyip13-Jul-05 16:11 
GeneralIIS Root Path location Pin
Sau Fan Lee12-Jul-05 17:28
Sau Fan Lee12-Jul-05 17:28 
GeneralRe: IIS Root Path location Pin
Expert Coming12-Jul-05 18:02
Expert Coming12-Jul-05 18:02 
GeneralMs Word Field Codes Pin
bootn12-Jul-05 17:05
bootn12-Jul-05 17:05 
GeneralRe: Ms Word Field Codes Pin
ekynox13-Jul-05 19:29
ekynox13-Jul-05 19:29 
GeneralSave as "TXT" File Pin
tatchung12-Jul-05 15:47
tatchung12-Jul-05 15:47 
Hi! Im trying to create a form with a button that saves the output as a "text" file. My problem is that this code compiles without any exceptions however it tends to hang at runtime. Can someone please tell me what is wrong with my code and if i'm missing anything. The output is bound to a grid and shows a couple of data based on my drop down list.

private void btnSave_Click(object sender, System.EventArgs e)
{
OdbcConnection cnn = new OdbcConnection();

cnn.Open();

OdbcCommand cmmd = new OdbcCommand();
OdbcDataAdapter adp = new OdbcDataAdapter (cmmd);
DataTable dt_emp = new DataTable();
adp.Fill(dt_emp);

System.Text.StringBuilder sb = new System.Text.StringBuilder();

for(int i=0;i<=dt_emp.Rows.Count - 1; i++)
{
for(int q=0;q<=dt_emp.Columns.Count - 1; q++)
{
sb.Append(dt_emp.Rows[i][q].ToString());
}
sb.Append("
");
}
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=*.txt");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.text";
System.IO.StringWriter strWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(strWrite);
Response.Write(sb.ToString());
}

Big Grin | :-D Big Grin | :-D Big Grin | :-D Big Grin | :-D Big Grin | :-D

dt_emp is the data passed. Thanx in advance for all your replies!!!
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 17:28
protectorChristian Graus12-Jul-05 17:28 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 17:36
tatchung12-Jul-05 17:36 
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 17:45
protectorChristian Graus12-Jul-05 17:45 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 17:53
tatchung12-Jul-05 17:53 
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 17:55
protectorChristian Graus12-Jul-05 17:55 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 18:03
tatchung12-Jul-05 18:03 
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 18:12
protectorChristian Graus12-Jul-05 18:12 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 18:23
tatchung12-Jul-05 18:23 
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 18:27
protectorChristian Graus12-Jul-05 18:27 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 18:34
tatchung12-Jul-05 18:34 
GeneralRe: Save as &quot;TXT&quot; File Pin
Christian Graus12-Jul-05 18:43
protectorChristian Graus12-Jul-05 18:43 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 18:50
tatchung12-Jul-05 18:50 
GeneralRe: Save as &quot;TXT&quot; File Pin
Luis Alonso Ramos13-Jul-05 6:36
Luis Alonso Ramos13-Jul-05 6:36 
GeneralRe: Save as &quot;TXT&quot; File Pin
Sau Fan Lee12-Jul-05 18:27
Sau Fan Lee12-Jul-05 18:27 
GeneralRe: Save as &quot;TXT&quot; File Pin
Expert Coming12-Jul-05 18:53
Expert Coming12-Jul-05 18:53 
GeneralRe: Save as &quot;TXT&quot; File Pin
tatchung12-Jul-05 21:44
tatchung12-Jul-05 21:44 
GeneralRe: Save as &quot;TXT&quot; File Pin
Tejas_Bit12-Jul-05 21:48
Tejas_Bit12-Jul-05 21:48 

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.