Vb script should read data from sql server based on variable value it should delete record

Author Message
Naveengudepu

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 2/5/2012
  • Status: offline
Vb script should read data from sql server based on variable value it should delete record Monday, February 06, 2012 5:29 AM (permalink)
0
Hi All,
 
I have a VB script which should read the data from sql server and store in variable and it has delete the data from file based on the varaible value.
Example if we got variable as 4 then we need to delete 4-1=3 first 3records from file.
 
Here is the script which i devloped but getting error.
'Sample code for Connecting to SQL SERVER Data Base & Fetch the Data from Data Base                        
 
 
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
Str_Connect = "Provider=SQLOLEDB;Data Source=WVDMD043;Initial Catalog=tempdb"
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
Set CnnSQL=CreateObject("ADODB.Connection")
 
CnnSQL.Open Str_Connect, "test", "test123"
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
If CnnSQL.State=1 Then
 
Msgbox "Connected"
 
else
 
Msgbox "Not Connected"
 
End If
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
Set Rs=CreateObject("ADODB.Recordset")
 
Set Rs=CnnSQL.Execute("select userid from ##axpert_global")
 
Do while not Rs.EOF
 
Msgbox (Rs(0) & space(3) & Rs(1) & space(3) & Rs(2) & space(3) & Rs(3))
 
Rs.MoveNext
 
Loop
 
<!--[if !supportEmptyParas]--> <!--[endif]-->
 
end
 __________
Appreciate your quick reply
 
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Vb script should read data from sql server based on variable value it should delete rec Monday, February 06, 2012 6:54 AM (permalink)
    0
    What is the specific error that you get. What exact line is the error occurring on?
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      59cobalt

      • Total Posts : 981
      • Scores: 91
      • Reward points : 0
      • Joined: 7/17/2011
      • Status: offline
      Re:Vb script should read data from sql server based on variable value it should delete rec Monday, February 06, 2012 6:58 AM (permalink)
      0
      Naveengudepu
      Here is the script which i devloped but getting error.
      So, what is the error you're getting?

       
      #3
        Naveengudepu

        • Total Posts : 10
        • Scores: 0
        • Reward points : 0
        • Joined: 2/5/2012
        • Status: offline
        Re:Vb script should read data from sql server based on variable value it should delete rec Tuesday, February 07, 2012 12:55 AM (permalink)
        0
        Following is the error message am getting
        "V:\test sqlserver\TestVbtoSql.vbs(6, 1) Microsoft VBScript compilation error: Ex pected statement"
        
         

         
        #4
          ebgreen

          • Total Posts : 8227
          • Scores: 98
          • Reward points : 0
          • Joined: 7/12/2005
          • Status: offline
          Re:Vb script should read data from sql server based on variable value it should delete rec Tuesday, February 07, 2012 3:11 AM (permalink)
          0
          How are you running this?
          "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
          Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
          http://www.visualbasicscript.com/m_47117/tm.htm
           
          #5
            Naveengudepu

            • Total Posts : 10
            • Scores: 0
            • Reward points : 0
            • Joined: 2/5/2012
            • Status: offline
            Re:Vb script should read data from sql server based on variable value it should delete rec Tuesday, February 07, 2012 10:24 PM (permalink)
            0
            Through ms dos command such as cscript filename.vbs
             
             
            #6
              59cobalt

              • Total Posts : 981
              • Scores: 91
              • Reward points : 0
              • Joined: 7/17/2011
              • Status: offline
              Re:Vb script should read data from sql server based on variable value it should delete rec Wednesday, February 08, 2012 1:29 AM (permalink)
              0
              cscript.exe (as well as wscript.exe) doesn't support HTML comment tags (<!--...-->).
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9