Click here to Skip to main content
16,004,833 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: WININET from VB 6 to VB .NET Pin
Vasudevan Deepak Kumar29-Jan-07 22:31
Vasudevan Deepak Kumar29-Jan-07 22:31 
QuestionFormatting an excel spreadsheet Pin
leckey29-Jan-07 9:03
leckey29-Jan-07 9:03 
AnswerRe: Formatting an excel spreadsheet Pin
Johan Hakkesteegt30-Jan-07 0:56
Johan Hakkesteegt30-Jan-07 0:56 
QuestionIsolated storage settings lost when I re-publish Pin
KreativeKai29-Jan-07 7:50
professionalKreativeKai29-Jan-07 7:50 
QuestionTrying to Customize the DataGridView cell values [modified] Pin
GWbasicProgrammer29-Jan-07 7:25
GWbasicProgrammer29-Jan-07 7:25 
QuestionMy.Setting StringCollection Pin
Marc Soleda29-Jan-07 6:56
Marc Soleda29-Jan-07 6:56 
AnswerRe: My.Setting StringCollection Pin
Christian Graus29-Jan-07 9:06
protectorChristian Graus29-Jan-07 9:06 
QuestionWSH - VB Script - use value got from an XML file Pin
Docteur_Z29-Jan-07 6:51
Docteur_Z29-Jan-07 6:51 
Hi,

I'm not a developper, but an Oracle DBA. I'm new to scripting in windows (better on unix). I tried to create a script to get configuration values that Oracle store in an XML file and use them. I encounter an error, which seems to be a object/variable type casting error :
C:\WinScripts\Myscript\switch_all_logs.vbs(73, 3) Erreur d'exécution Microsoft VBScript: Objet requis: '[string: "C:\oracle\ora92"]'

My code :
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
'Title        : switch_all_logs.vbs<br />
'Description  : Switch All Oracle RDBMS logfiles<br />
'Author       : G.Reboute<br />
'Company      : <br />
'Created      : 29/01/2007<br />
'Rel.         : 1.0<br />
'Rel. Date    : 29/01/2007<br />
'Purpose      : to rename <namefile.log> into <namefile.log.YYYYMMDD><br />
'Note         : produces a log of the executed actions in the execution <br />
'               directory named "switch.log" and an Application Log entry also<br />
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
Option Explicit<br />
'Variables<br />
Dim WSHShell, objArgs, XMLread, XMLreader<br />
Dim strOracleRegKey, strInvLoc, strOracleHome, retcode, strDir<br />
Dim xmlDoc, xmlHomeList, xmlRoot, xmlNode, myErr, i<br />
Dim oFileSys, xmlAttrib, toto<br />
<br />
' On est oblige de ne pas tenir compte des erreurs au debut du script<br />
' car la methode RegRead ne renvoit pas de code erreur "attrapable"<br />
Err.Clear<br />
On Error Resume Next<br />
Set WSHShell = WScript.CreateObject("WScript.Shell")<br />
Set objArgs = WScript.Arguments<br />
Set oFileSys = CreateObject("Scripting.FileSystemObject") <br />
strDir = oFileSys.GetAbsolutePathName(".\")<br />
<br />
' Lecture du repertoire d'inventory Oracle<br />
strOracleRegKey = "HKLM\software\oracle\inst_loc"<br />
strInvLoc = WSHShell.RegRead(strOracleRegKey)<br />
If Err.number <> 0 then<br />
WScript.Echo("L'erreur de lecture de la cle = " & Err.number)<br />
' Si ce n'est pas defini on essaye a l'emplacement par défaut<br />
strInvLoc = "C:\Program Files\Oracle\Inventory"<br />
End if<br />
' On remet en route la gestion des erreurs<br />
On Error goto 0<br />
<br />
'Creation du Document Xml<br />
Set xmlDoc = CreateObject("Microsoft.XMLDOM") <br />
'WScript.Echo("Le fichier = " & strInvLoc & "\ContentsXML\inventory.xml")<br />
<br />
' Chargement du XML et gestion des erreurs<br />
xmlDoc.Load(strInvLoc & "\ContentsXML\inventory.xml")<br />
If xmlDoc.parseError.errorCode <> 0 Then<br />
    myErr = Err.Description & vbCrLf<br />
    myErr = myErr & xmlDoc.parseError.reason & " ligne: " & _      <br />
            xmlDoc.parseError.Line & " col: " & _<br />
            xmlDoc.parseError.linepos & _<br />
            " texte: " & xmlDoc.parseError.srcText<br />
    MsgBox myErr, vbCritical, "Une erreur est apparue durant le chargement"<br />
    WScript.Quit 1<br />
End If<br />
<br />
' xmlRoot est l'image du document en "pur" XML<br />
Set xmlRoot = xmlDoc.DocumentElement<br />
'WScript.Echo(root.xml)<br />
<br />
' On se positionne sur le bon noeud<br />
Set xmlHomeList = xmlRoot.SelectNodes("HOME_LIST/HOME")<br />
If xmlHomeList.length <=0 then<br />
   WScript.Echo("Je n'ai rien pu trouver pour HOME_LIST/HOME")<br />
   WScript.Echo("Etes vous bien sur qu'il s'agisse d'un fichier d'inventaire Oracle ?")<br />
   WScript.Quit 2<br />
End if<br />
'WScript.Echo("On passe a la recherche proprement dite" & VBCRLF & VBCRLF & VBCRLF )<br />
i = 0<br />
For Each xmlNode In xmlHomeList<br />
'  WScript.Echo(xmlNode.nodeName)<br />
  Set xmlAttrib = xmlNode.Attributes.getNamedItem("LOC")<br />
' The error appears on the next line<br />
  Set strOracleHome = xmlAttrib.Value<br />
  Wscript.Echo "Oracle Home " & i & " = " &  strOracleHome<br />
  Wscript.Echo "Current Dir = " & strDir<br />
  Wscript.Echo "Commande = " & strDir & "\switchlistenerlog.vbs " & chr(34) & xmlAttrib & chr(34)<br />
'  retcode = WSHShell.Run(strDir & "\switchlistenerlog.vbs " & chr(34) & xmlAttrib & chr(34), 1)<br />
  If retcode <> 0 Then<br />
    WScript.Echo("script de switch des logs du listener introuvable")<br />
    WScript.Quit 3<br />
  End If<br />
  Set strOracleHome = Nothing<br />
  Set xmlAttrib = Nothing<br />
  i = i + 1<br />
Next<br />


The XML file (I had to add the spaces to show it on the board):
<br />
< ?xml version="1.0" standalone="yes" ?><br />
< !-- Copyright (c) 2005 Oracle Corporation. All rights Reserved --><br />
< !-- Do not modify the contents of this file by hand. --><br />
< INVENTORY><br />
< VERSION_INFO><br />
   < SAVED_WITH>10.2.0.1.0</SAVED_WITH><br />
   < MINIMUM_VER>2.1.0.6.0</MINIMUM_VER><br />
< /VERSION_INFO><br />
< HOME_LIST><br />
< HOME NAME="OraHome92" LOC="C:\oracle\ora92" TYPE="O" IDX="1"/><br />
< HOME NAME="OraHomeClient10g" LOC="C:\oracle\10.2.0\client" TYPE="O" IDX="2"/><br />
< /HOME_LIST><br />
< /INVENTORY><br />

When I make an echo of xmlNode.Attributes.getNamedItem("LOC"), it's OK, I get the value of the attribute, but when I want to use it as a string, I got the error.
QuestionGetFiles versus GetDirectories Pin
GeorgieMPorgie29-Jan-07 4:56
GeorgieMPorgie29-Jan-07 4:56 
AnswerRe: GetFiles versus GetDirectories Pin
TwoFaced29-Jan-07 6:47
TwoFaced29-Jan-07 6:47 
GeneralRe: GetFiles versus GetDirectories Pin
GeorgieMPorgie30-Jan-07 5:16
GeorgieMPorgie30-Jan-07 5:16 
QuestionHow To Create Alert Message Box In System Try Pin
Ankush Komarwar29-Jan-07 3:56
Ankush Komarwar29-Jan-07 3:56 
AnswerRe: How To Create Alert Message Box In System Try Pin
Guffa29-Jan-07 4:36
Guffa29-Jan-07 4:36 
AnswerRe: How To Create Alert Message Box In System Try Pin
Nilesh Hapse30-Jan-07 1:07
Nilesh Hapse30-Jan-07 1:07 
Question[PPC] Event when loaded ... [modified] Pin
ChPortos29-Jan-07 3:32
ChPortos29-Jan-07 3:32 
Questiontemporary internet files Pin
wullie5829-Jan-07 1:59
wullie5829-Jan-07 1:59 
AnswerRe: temporary internet files Pin
Vasudevan Deepak Kumar29-Jan-07 22:34
Vasudevan Deepak Kumar29-Jan-07 22:34 
QuestionInt value into word do Pin
harveyhanson29-Jan-07 1:39
harveyhanson29-Jan-07 1:39 
AnswerANYONE??? Pin
harveyhanson29-Jan-07 12:53
harveyhanson29-Jan-07 12:53 
GeneralRe: ANYONE??? Pin
Christian Graus29-Jan-07 13:40
protectorChristian Graus29-Jan-07 13:40 
GeneralRe: ANYONE??? Pin
harveyhanson29-Jan-07 15:06
harveyhanson29-Jan-07 15:06 
GeneralRe: ANYONE??? Pin
Christian Graus29-Jan-07 15:53
protectorChristian Graus29-Jan-07 15:53 
GeneralRe: ANYONE??? Pin
harveyhanson30-Jan-07 5:30
harveyhanson30-Jan-07 5:30 
QuestionHow do i get the name of control where i pressed the contextmenu Pin
.NetRams29-Jan-07 0:56
.NetRams29-Jan-07 0:56 
AnswerRe: How do i get the name of control where i pressed the contextmenu Pin
Vikash Yadav29-Jan-07 1:21
Vikash Yadav29-Jan-07 1:21 

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.