Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2005, 08:21 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Anup Gavate Send a message via Yahoo to Anup Gavate
Default 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

 
Old March 25th, 2005, 01:54 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Do you think you could let us in on which line it is that throws the error?...

Tip: I suggest that you take out [u]ALL</u> exclamation marks from all prompts and messages. Just the fact that the program has anything to say at all is usually exclamatory enough; exclamation marks convey shouting, and most people quickly get tired of being shouted at...
 
Old March 28th, 2005, 12:26 PM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Anup Gavate Send a message via Yahoo to Anup Gavate
Default

Hi Brian,

I think that's not issue though i removed and tried same code. Still displaying same error. I need more help.

 
Old March 28th, 2005, 01:45 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I didn't say that was the problem... I explicitly said it was a tip.

I asked you a question; are you going to answer it? (Please read these posts carefully: it will save all involved a lot of time...)

Again I ask: Which line throws the error?
 
Old March 28th, 2005, 01:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

could it be this the error???

Set txtStream = txtFileObject.OpenAsTextStream(ForReading)


Openastextstream??? if that an object function????

HTH

Gonzalo





Similar Threads
Thread Thread Starter Forum Replies Last Post
type mismatch frresh Pro Visual Basic 2005 1 April 11th, 2006 08:35 AM
Type mismatch NoBullMan Classic ASP Basics 2 November 16th, 2004 03:16 AM
Type mismatch per.holleufer Classic ASP Basics 5 July 31st, 2004 07:33 AM
Type mismatch sporkman43 Classic ASP Basics 4 August 14th, 2003 03:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.