vbscript how to copy from database to text file

Copy records in database to the text file

Page 1 of 1

1 Replies - 1888 Views - Last Post: 11 September 2009 - 12:49 AM Rate Topic: -----

#1 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

vbscript how to copy from database to text file

Posted 10 September 2009 - 01:56 AM

hi all,

I have records in table1 and i want to copy them into text files. Can it to be done? I have example in c# codes, but it using streamWriter. If in FileSystemObject what methods should we use? I have solution in c# code, but it using streamWriter. I wanna code using VBScript WSH, and my database is MSSQL 2005 Server.

Any solution, references, or guide are very thankful..thanks
using (StreamWriter tw = File.AppendText("c:\\INMS.txt"))
				{
					using (SqlDataReader reader = cmd.ExecuteReader())
					{
						tw.WriteLine("id, ip address, message, datetime");
						while (reader.Read())
						{
							tw.Write(reader["id"].ToString());
							tw.Write(", " + reader["ip"].ToString());
							tw.Write(", " + reader["msg"].ToString());
							tw.WriteLine(", " + reader["date"].ToString());
						}
						tw.WriteLine("Report Generate at : " + DateTime.Now);
						tw.WriteLine("---------------------------------");
						tw.Close();
						reader.Close();
					}					
				}


This post has been edited by dunk_6: 10 September 2009 - 01:58 AM


Is This A Good Question/Topic? 0
  • +

Replies To: vbscript how to copy from database to text file

#2 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

Re: vbscript how to copy from database to text file

Posted 11 September 2009 - 12:49 AM

Hi all..

I already found the solution. I need to put ADODB objects and the FileSystemObject from the Scripting library.

thank you.

p/s: do i need to close this topic? How ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1