Type Mismatch
Hi all,
Please help me to get out of this big big trouble.
Following code is not working and displaying error "Type Mismatch" although 'conn.ini' file is created.
I need to create a file is not exists via 'conn.ini' and write to it the user name, password, remote server name and database name. If exists then just read data from the file. Let me know if there is any thing wrong with my code.
Please let me know if i need to include any reference file other than scrrun.dll to execute following code or whether there is any syntax error.
Dim fsoObject As New Scripting.FileSystemObject
Dim txtFileObject As Scripting.File
Dim txtStream As TextStream
If fsoObject.FileExists("c:\conn.ini") Then
MsgBox "Exists!!!"
Set txtFileObject = fsoObject.CreateTextFile("c:\conn.ini", True)
Set txtStream = txtFileObject.OpenAsTextStream(ForReading)
MsgBox txtStream.ReadLine
txtStream.Close
MsgBox "File created and data written to the file!!!"
Else
MsgBox "Not Exists!!!"
Set txtFileObject = fsoObject.CreateTextFile("c:\conn.ini", True)
Set txtStream = txtFileObject.OpenAsTextStream(ForWriting)
txtStream.WriteLine ("[StartUp]")
txtStream.WriteLine ("UID=sa")
txtStream.WriteLine ("Password=manish")
txtStream.WriteLine ("Server=Anup")
txtStream.WriteLine ("DBName=thanksdarling")
txtStream.Close
MsgBox "File created and data written to the file!!!"
End If
Set txtStream = Nothing
Set txtFileObject = Nothing
Set fsoObject = Nothing
|