Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 357505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:12:42+00:00 2026-05-12T12:12:42+00:00

I have a table and a text file. Once the records in the table

  • 0

I have a table and a text file. Once the records in the table copied into textfile, the records will be deleted. But the table are still in used and will be inserted with a new records from time to time(by another program). I what to do checking on How to make sure that if there are no records in the table, the program will never copy into textfile.

Any solution, or references are very thankful. Thank you very much. Im testing in WSH and using MSSQL Server 2005.

'call functions
  call CopyFile()
  call tblDelete()
Sub tblDelete() Dim sql1 sql1 = "DELETE from tblOutbox" rs = conn.Execute(sql1) End Sub
Sub CopyFile 'set the sql command cmd.CommandText = "SELECT * FROM tblOutbox" cmd.CommandType = 1 ''# adCmdText Command text is a SQL query Dim rs : Set rs = cmd.Execute 'create obj for the FileSystem Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFile, objFolder
Dim strDir, strFile strDir = "c:\" strFile = "\newFile.txt" 'check that the strDirectory folder is exist If objFSO.FolderExists(strDir) Then Set objFolder = objFSO.GetFolder(strDir) Else Set objFolder = objFSO.CreateFolder(strDirectory) WScript.Echo "Just created " & strDir End If If objFSO.FileExists(strDir & strFile) Then Set objFolder = objFSO.GetFolder(strDir) Else Set objFile = objFSO.CreateTextFile(strDir & strFile) Wscript.Echo "Just created " & strDir & strFile End If Set objFile = Nothing Set objFolder = Nothing 'open files and copy into
Dim objtextStream : Set objtextStream = objFSO.OpenTextFile(strDir & strFile, 8, True) Do Until rs.EOF objtextStream.Write rs("id") & ", "
objtextStream.Write rs("ip") & ", " objtextStream.Write rs("msg") & ", " objtextStream.WriteLine rs("date")
rs.MoveNext Loop objTextStream.WriteLine objTextStream.WriteLine "Report Generate at " & Now objTextStream.WriteLine "--------------------------------------------" objtextStream.Close rs.Close
End Sub

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:12:42+00:00Added an answer on May 12, 2026 at 12:12 pm

    You could put

    If rs.RecordCount > 0 Then
       exit sub
    End If
    

    before

    Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objFile, objFolder 
    

    i.e. Don’t execute any of the statements, if there are no records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a TEXT column where the contents is just strings
I am using SQL Server 2005. I have a table with a text column
I have a table containing cells with text of various lengths. It is essential
I have a table with each cell containing a label and a text field.
In a SQL server database, I have a table which contains a TEXT field
I have a products table... alt text http://img357.imageshack.us/img357/6393/productscx5.gif and a revisions table, which is
I have data from a table in a database (string) that contain text and
I have this input text: <html><head><meta http-equiv=content-type content=text/html; charset=utf-8></head><body><table cellspacing=0 cellpadding=0 border=0 align=center width=603>
I have table inside a div tab. The table has 40 rows in it
I have two tables: articles and articletags articles: id, author, date_time, article_text articletags: id,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.