Results 1 to 26 of 26

Thread: need some help connecting to SQL SERVER 2014 connection string

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    need some help connecting to SQL SERVER 2014 connection string

    hey,
    its been a half hour that i am trying to connect to sql server 2014 with a connection string
    I search the web all kind of codes
    nothing works for me
    please i need some help
    i added some samples i tried to use
    Code:
    Dim ConnectionString As String
    Dim Cn As ADODB.Connection
    Set CN = New ADODB.Connection
    ConnectionString = "Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID='';Initial 
    
    Catalog=BeautyDesign;Data Source=SQLSERVER;Initial File Name='';Server SPN='' "
    
    ConnectionString = "Provider=SQLNCLI10;Server=10.1.100.1;Database=BeautyDesign;Uid=sa;Pwd=sa;"
    
    CN.Open "Driver=SQL Server;Server=.\SQLEXPRESS;Database=BeautyDesign;uid=sa;pwd=sa;"
    
    ConnectionString = "Provider=SQLNCLI10; DRIVER=Sql Server; SERVER=TECH-PC\SQLEXPRESS; DATABASE=BeautyDesign; UID=sa; PWD=sa"
    CN.ConnectionString = ConnectionString
    CN.Open
    tnx for any help
    salsa

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,152

    Re: need some help connecting to SQL SERVER 2014 connection string

    These might help
    thinBasic Code:
    1. '--- standard security
    2. sConnStr = "Provider=SQLOLEDB" & _
    3.     ";Data Source=" & sSqlServer & _
    4.     ";Initial Catalog=" & sSqlDb & _
    5.     ";User ID=" & sDbUser & ";Password=" & sDbPass
    6.  
    7. '--- integrated security
    8. sConnStr = "Provider=SQLOLEDB" & _
    9.     ";Data Source=" & sSqlServer & _
    10.     ";Initial Catalog=" & sSqlDb & _
    11.     ";Integrated Security=SSPI"
    cheers,
    </wqw>

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    there is no password
    no its not helping my friend

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,152

    Re: need some help connecting to SQL SERVER 2014 connection string

    Did you try using '--- integrated security snippet then? Does connecting from SSMS (SQL Server Management Studio) work?

    cheers,
    </wqw>

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: need some help connecting to SQL SERVER 2014 connection string

    ConnectionStrings.com is a good site for almost any connection string example.

    In the examples posted by wqweto, simply don't include the parts of the connection string that do not apply, i.e., the password and user ID.

    I think you should post the exact error you are getting
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    I notice you use sa for the login in all the attempts. Is SQL Server configured to use the SQL Server Login, Windows Login, or Both?

    You also say there is no password but you are specifying a password in each of those strings. To the best of my knowledge there will always be a password when using SQL server.

    sa only works if configured to use SQL Server login and the default sa account is present.

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    Name:  Untitled1.jpg
Views: 329
Size:  58.2 KB
    Name:  Untitled2.jpg
Views: 344
Size:  45.9 KB
    Name:  Untitled3.jpg
Views: 422
Size:  69.8 KB
    the test connectios is ok

  8. #8

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    when i use this
    Code:
    Dim ConnectionString As String
    ConnectionString = "Provider=SQLNCLI11;Integrated Security=SSPI;Persist Security Info=False;User ID='';Initial Catalog=BeautyDesign;Data Source=.\SQLEXPRESS;Initial File Name='';Server SPN='' "
    CN.ConnectionString = ConnectionString
    CN.Open
    i dont get any errors
    and the sql sever is not connected yet

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    You are specifying a blank user ID.

    Your ODBC connection above is using your windows login info.

  10. #10
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,152

    Re: need some help connecting to SQL SERVER 2014 connection string

    This should work then
    thinBasic Code:
    1. sConnStr = "Provider=SQLOLEDB" & _
    2.     ";Data Source=" & "TECH-PC\SQLEXPRESS" & _
    3.     ";Initial Catalog=" & "master" & _
    4.     ";Integrated Security=SSPI"
    cheers,
    </wqw>

  11. #11

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by DataMiser View Post
    You are specifying a blank user ID.

    Your ODBC connection above is using your windows login info.
    i dont have any passwords in windows sir

  12. #12

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    I think you should post the exact error you are getting
    i dont get any errors yet sir
    and the sql sever is not connected yet

  13. #13
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,152

    Re: need some help connecting to SQL SERVER 2014 connection string

    In an empty Std-Exe project add a reference to Microsoft ActiveX Data Objects 2.8 Library and try this code in the default Form1
    thinBasic Code:
    1. Private Sub Form_Load()
    2.     Dim sConnStr As String
    3.    
    4.     sConnStr = "Provider=SQLOLEDB" & _
    5.         ";Data Source=" & "TECH-PC\SQLEXPRESS" & _
    6.         ";Initial Catalog=" & "master" & _
    7.         ";Integrated Security=SSPI"
    8.     With New ADODB.Connection
    9.         .Open sConnStr
    10.         .CursorLocation = adUseClient
    11.         Debug.Print .OpenSchema(adSchemaCatalogs).RecordCount
    12.     End With
    13. End Sub
    What errors do you get?

    cheers,
    </wqw>

  14. #14

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    this is when i use access
    Code:
    Set CN = New ADODB.Connection
    StrSQL = "Provider=Microsoft.Jet.OLEDB.4.0;"
    StrSQL = StrSQL & "Data Source=" & App.Path & "\BeautyDesign.mdb;"
    StrSQL = StrSQL & "Jet OLEDB:Database Password=035924794"
    CN.ConnectionString = StrSQL
    CN.Open
    i didint add any password to sql

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by salsa31 View Post
    i dont have any passwords in windows sir
    Not sure what you mean there. I said you are giving a blank user ID.

    Been a while since I dived into it but pretty sure that you can not install Windows without a password anymore.
    I've had all my systems password protected in every version of windows from 95 on.

  16. #16
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by salsa31 View Post
    this is when i use access
    Code:
    Set CN = New ADODB.Connection
    StrSQL = "Provider=Microsoft.Jet.OLEDB.4.0;"
    StrSQL = StrSQL & "Data Source=" & App.Path & "\BeautyDesign.mdb;"
    StrSQL = StrSQL & "Jet OLEDB:Database Password=035924794"
    CN.ConnectionString = StrSQL
    CN.Open
    i didint add any password to sql
    Passwords are added to SQL Server during install. If you choose the integrated windows mode then it uses your windows user name and password that you logged into windows with.

  17. #17

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    well sir i use windows 7 and i have no password
    anyway funny thing is
    when i use the string connection
    Code:
    Dim ConnectionString As String
    ConnectionString = "Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID='';Initial Catalog=BeautyDesign;Data Source=.\SQLEXPRESS;Initial File Name='';Server SPN='' "
    CN.ConnectionString = ConnectionString
    CN.Open
    i can see the data load to the combobox But
    when i am trying to check something then i get a error
    Code:
        Dim Rs As New ADODB.Recordset
        Rs.Open "Select * From Users Where UserName = '" & CmbUserName.Text & "'", CN
        If TxtPassWord.Text <> Rs!UserPass Then
    Name:  Untitled8.jpg
Views: 286
Size:  20.9 KB

  18. #18
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    The message is telling you that there was no match to your query

    As for the password are you sure that you do not have one? As I recall Windows asks you for the admin password during install. I'm not sure if it can be left blank, I know on older versions you could set up an account without a password but you could not use networking properly if you did not have a password.

  19. #19
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: need some help connecting to SQL SERVER 2014 connection string

    Good news, you are connecting to your database.

    FYI:
    If rs.EOF is True, recordset position is after the final record. Moving next generates an error
    If rs.BOF is True, recordset position is before the first record. Moving previous generates an error
    If both .EOF and .BOF are true, there are no records in the recordset
    If either .BOF or .EOF are true, attempting to access a record property/value generates an error
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #20

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by DataMiser View Post
    The message is telling you that there was no match to your query

    As for the password are you sure that you do not have one? As I recall Windows asks you for the admin password during install. I'm not sure if it can be left blank, I know on older versions you could set up an account without a password but you could not use networking properly if you did not have a password.
    yes sir im a sure
    well i got connected some how to the server
    i dont think it is to the sql beacuse it is disconnected and still i can login
    for eof or bof i just use
    Code:
    if not rs.eof ' i know this :)

  21. #21

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    i dont think i am connecting to the SQL server
    beacuse its disconnected and still shows me username and passwords
    very strange

  22. #22
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    Hard to tell based on the small amount of code shown, Are those pieces of code in the same routine?

  23. #23

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by DataMiser View Post
    Hard to tell based on the small amount of code shown, Are those pieces of code in the same routine?
    those are codes that i try to make the connection
    im not using it all at once

  24. #24
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by salsa31 View Post
    those are codes that i try to make the connection
    im not using it all at once
    Like I said it is hard to tell what kind of problem you are having from just that little bit of code, harder still if they are in different routines. For all I know you have some other code executing that is looking in an access database and is why you are seeing data.

  25. #25

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: need some help connecting to SQL SERVER 2014 connection string

    Quote Originally Posted by DataMiser View Post
    Like I said it is hard to tell what kind of problem you are having from just that little bit of code, harder still if they are in different routines. For all I know you have some other code executing that is looking in an access database and is why you are seeing data.
    hey sir
    there is no connection to access at all
    Last edited by salsa31; May 22nd, 2018 at 08:30 AM.

  26. #26
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: need some help connecting to SQL SERVER 2014 connection string

    The problem is that you only showed a couple of lines of code that are apparently in two different routines, You also show an error that indicates you are not getting a match to your query but you have given no real details to help figure out what the problem may be nor what else may be going on in your program between those lines of code.

    If there is a problem with the connection then you will get an error when you try to open the connection not when you try to read data from a recordset.

    Try this code in a single routine and see what you get in the debug window
    Code:
    On Error GoTo ErrTrap
    Dim ConnectionString As String
    ConnectionString = "Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID='';Initial Catalog=BeautyDesign;Data Source=.\SQLEXPRESS;Initial File Name='';Server SPN='' "
    CN.ConnectionString = ConnectionString
    CN.Open
    Dim Rs As adodb.Recordset
    Set Rs = New adodb.Recordset
    Rs.Open "Select * From Users Where UserName = '" & CmbUserName.Text & "'", CN
    If Not Rs.EOF Then
        Debug.Print Rs!UserPass
    Else
        Debug.Print "No match found"
    End If
    Exit Sub
    ErrTrap:
    Debug.Print Err.Description
    If you get an error then set a break point at the top and step through the code to see where it occurs

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