Results 1 to 18 of 18

Thread: [RESOLVED] SqlClient.SqlConnection not working.

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Resolved [RESOLVED] SqlClient.SqlConnection not working.

    This line of code has been working to my SQL 2000 instance on my laptop for months.

    Now I'm trying to connect to a network server - and it's failing. That server is running SQL 2005.

    Do I have to install something on the network server to get this to work for me??

    Code:
    Imports System.Data.SqlClient
    .
    .
    .
    Dim LDcn As New SqlConnection
    Dim booGoodLoad As Boolean = False
    LDcn.ConnectionString = "Data Source=" & APCSettings.sServer _
              & "; Initial Catalog=" & APCSettings.sDatabase  _
              & "; Integrated Security=SSPI; User Id=" _
              & APCSettings.sUserId & "; Password=" & strPassword

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SqlClient.SqlConnection not working.

    Ok - it's even worse - I just tried this:

    Code:
    Imports System.Data.SqlClient
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Dim LDcn As New SqlConnection
            LDcn.ConnectionString = "Data Source=fps-lap-sz; Initial Catalog=Stufiles; User Id=apcload; Password=apcload"
            Try
                LDcn.Open()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    End Class
    Back to opening a connection on my laptop - something that worked back in this thread months ago

    http://www.vbforums.com/showthread.php?t=460915

    And now I'm getting:

    ?ex.Message
    "Specified SQL server not found: fps-lap-sz"

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SqlClient.SqlConnection not working.

    Ok - I just started a new project - not a Pocket PC 2003 project but just a regular windows app

    Put this same code in

    Code:
    Imports System.Data.SqlClient
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Dim LDcn As New SqlConnection
            LDcn.ConnectionString = "Data Source=fps-lap-sz; Initial Catalog=Stufiles; User Id=apcload; Password=apcload"
            Try
                LDcn.Open()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    End Class
    and it found the server and opened the database fine.

    Why would VS under a PPC 2003 app not let this exact same code work?

    I did have to add two ref's for the PPC 2003 app - System.Data and System.Data.SqlClient.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: SqlClient.SqlConnection not working.

    Hi,
    the string i use to connect to a Sql2000 base is "Persist Security Info=False;Integrated Security=False;Server=delldesktop,39250;initial catalog=Waiter;user id=sa;password=;"

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Resolved Re: SqlClient.SqlConnection not working.

    @Petevick - I resolved this (I do believe) after installing a couple of downloads from MS and selecting "repair" - SQL CE was one of them - not even sure what the other one was.

    So I'm back to normal - can open the SQL 2000 and SQL 2005 DB's with any of the connection strings I showed above.

    btw - we need to use Windows Authentication - that's why my first post has the SSPI along with Windows Un/Pw.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    This is back to [NOT RESOLVED].

    Having problems opening network DB's from my laptop using the emulator. Seems that it's "only" seeing the local sql server 2005 express on the laptop - that is grabbing the connection even though we are asking to open a network DB.

    Anyone else ever experience this?

    Anyone know of MS acknowledging this error or releasing fixes for it?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    I don't if it is mentioned before but u should ip address for server not Name...like Server = 192.168.1.2,1433
    At least this works for me

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    how are you trying to open the database from the emulator (ie what is the connection string?)
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Ok - sorry it takes me so long to get back in - Sept is busy in the k-12 school marketplace...

    This code

    Code:
    Dim LDcn As New SqlConnection
    Dim booGoodLoad As Boolean = False
    LDcn.ConnectionString = "Server=" & APCSettings.sServer & "; Initial Catalog=" & APCSettings.sDatabase & "; Integrated Security=SSPI; User Id=" _
                                                                    & APCSettings.sUserId & "; Password=" & strPassword
    Try
        LDcn.Open()  ' This line of code works on the DEVICE - not on the EMULATOR!
    Catch ex As SqlException
        If ex.Number = 18452 Then
            MessageBox.Show("Invalid password - try again!")
        Else
            MessageBox.Show(ex.Message, "Error")
        End If
        Exit Sub
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Error")
        Exit Sub
    End Try
    works nicely with a PPC docked - using the "Pocket PC 2003 Device" itself - and not the emulator.

    Here is the simple connection sting

    Code:
    ?ldcn.ConnectionString
    "Server=Fpssql05; Initial Catalog=stufiles; Integrated Security=SSPI; User Id=szlamany; Password=xxx"
    
    * It has a password - that's how SSPI works from the PPC to the network
    * After the connection opens - after stepping over that line of code
    * the connection string changes to the following...
    
    ?ldcn.connectionstring
    "Server=Fpssql05; Initial Catalog=stufiles; Integrated Security=SSPI; User Id=szlamany;"
    The server is called Fpssql05 - I am sitting in my dining room VPN connected to this large WAN - and that is the server name on the network.

    @masteripper : I do not need to use the IP address - it's working fine

    I currently just "stepped" past the LDcn.Open() statement in code.

    And it's working in production for fifty users who work on that network.

    Now I change VS to "Pocket PC 2003 SE Emulator" and run the project.

    I get the exact same connection string

    Code:
    ?ldcn.ConnectionString
    "Server=Fpssql05; Initial Catalog=stufiles; Integrated Security=SSPI; User Id=szlamany; Password=xxx"
    I get this error message

    Code:
    ?ex.Number
    6
    ?ex.Message
    "Specified SQL server not found: Fpssql05"
    Nothing has changed just now except using a different device - the emulator.

    Now - I've got a spare PPC - I'll dock that one.

    It's deploying the NETCFv2.wm.ARMV4I.cab file and others - deploy succeeded...

    Run fails - can't find PInvoke DLL 'sqlceme30.dll'...

    Well that's enough in one post - I've got to look into why this spare PPC isn't working...
    Last edited by szlamany; Oct 13th, 2008 at 05:00 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Have you tried it with a 'docked' emulator??
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Quote Originally Posted by petevick
    Have you tried it with a 'docked' emulator??
    Docked emulator? And isn't the emulator always docked?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Hi,
    sorry - meant 'cradled' try from VS2005
    Tools>Device Emulator Manager
    Then right click on your connected emulator, and choose 'cradle' - you should be able to see the network completely then
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  13. #13

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    I cradled it in VS and got the same error.

    I never needed to manage the cradling of the emulator before - I've seen that window but never did anything with it.

    Does it normally just come up cradled by default?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  14. #14
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    cradling it allows it to 'see' the network, so you should be able to use PIE etc
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  15. #15
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Well i have to find some little time to try it but i trust you....
    This is probably going to save me some serious time.Time to move on

  16. #16

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Quote Originally Posted by petevick
    cradling it allows it to 'see' the network, so you should be able to use PIE etc
    PIE? Pocket IE?

    When I try to use IE from the PPC I'm getting "no network or modem"...

    When I try to use Term Serv Client - I cannot connect to the server called FPSSQL05.

    What kind of network am I supposed to see from the PPC?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  17. #17
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: [RESOLVED] SqlClient.SqlConnection not working.

    Hi,
    it should connect to activesync, so then you should be able to see the network as you would from a 'cradled' device.

    Obviously, it won't connect through activesync if you already have a device connected - otherwise, it works exactly like a cradled device.

    PIE - Pocket IE


    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  18. #18

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SqlClient.SqlConnection not working.

    I got this solved from a MS forum

    And you have cradled the emulator? (In AciveSync, File, Connection Settings, allow connections via: DMA, in Device Emulator Manager, right click the device, and select Cradle)
    I had changed the ACTIVESYNC to INFRARED connections sometime back - it needed to be set to DMA.

    I don't know why an ACTIVESYNC setting would have anything to do with SQLCLIENT.SQLCONNECTION - but it did.

    This is now working.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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