Results 1 to 5 of 5

Thread: [RESOLVED] Problem with sql conection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    256

    Resolved [RESOLVED] Problem with sql conection

    i always did like this
    Code:
    cn.Provider = "SQLOLEDB"
    cn.Properties("Data Source").Value = "127.0.0.1,1433"
    cn.Properties("Initial Catalog").Value = "LevelDB"
    cn.Properties("User ID").Value = "sa"
    cn.Properties("Password").Value = "123456"
    
    cn.Open
    but now, i got the run-time error '3705'

    why am i doing wrong?






  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Problem with sql conection

    What is the error description?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Problem with sql conection

    try just the IP address... no port... the default port is 1433, so it's not necessary to specify it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Problem with sql conection

    If the description is "Operation is not allowed when the object is open" then you should close it before opening.
    Code:
    cn.Provider = "SQLOLEDB"
    cn.Properties("Data Source").Value = "127.0.0.1,1433"
    cn.Properties("Initial Catalog").Value = "LevelDB"
    cn.Properties("User ID").Value = "sa"
    cn.Properties("Password").Value = "123456"
    
    If cn.state = adStateOpen Then
        cn.Close
    End If
    cn.Open
    Or you just have to open it if it is closed.
    Code:
    If cn.state = adStateClosed Then
        cn.Open
    End If
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    256

    Re: Problem with sql conection

    thanks, i was using a wrong if with exit sub without checking if the connection was realy opened, so it were opened, and when i try to open again return the error.

    thanks, with both answers i could see my error. thanks a lot.






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width