Results 1 to 4 of 4

Thread: [RESOLVED] Help with MS SQL Server Connection String

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Resolved [RESOLVED] Help with MS SQL Server Connection String

    So I installed MS SQL with all the default options. During the installation it asked me for a root password. I entered "aTest1!"

    When I open up the management tools I get this:


    I just hit connect and then made a new database called "timesheet1".

    Now it is time to connect via vb.net.

    I went to www.connectionstrings.com and got this string:
    Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

    I have tried all of the following:
    Data Source=PGUNNEWIEK-TM77\SQLEXPRESS;Initial Catalog=timesheet1;User Id=C3BRESLAU\pgunnewiek; Password=aTest1!;

    Data Source=PGUNNEWIEK-TM77\SQLEXPRESS;Initial Catalog=timesheet1;User Id=C3BRESLAU\pgunnewiek;

    Data Source=PGUNNEWIEK-TM77\SQLEXPRESS;Initial Catalog=timesheet1;User Id=pgunnewiek;

    Every time I get login failed.

    I have never worked with SQL before so I am not sure what I am doing wrong.

    The code I am using is from a codebank example on these forums. It can be seen below:
    Code:
    Imports System.Data.SqlClient
    
    Module Module1
        Sub Main()
            Dim ConnectionString = "PGUNNEWIEK-TM77\SQLEXPRESS;Initial Catalog=timesheet1;User Id=C3BRESLAU\pgunnewiek; Password=aTest1!;"
    
            ' Check if the Employee is already in the Database
            Using connection As New SqlConnection(ConnectionString)
                Using command As New SqlCommand("SELECT NameFirst, NameLast FROM Employees", _
                                              connection)
                    connection.Open()
                    Using reader As SqlDataReader = command.ExecuteReader()
                        While reader.Read()
                            Console.WriteLine(reader)
                        End While
                    End Using
                End Using
            End Using
    
        End Sub
    End Module
    Last edited by dethredic; Mar 22nd, 2010 at 09:52 AM.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Help with MS SQL Server Connection String

    You should not be using
    User Id=myUsername;Password=myPassword

    Use Trusted_Conenction = TRUE

    Since this is SQLExpress then the servername is: PGUNNEWIEK-TM77\SQLEXPRESS
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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

    Re: Help with MS SQL Server Connection String

    Head back over to connectionstrings.com ... find the connection string for SQL Server with integrated security... odds are, that's the one you want.

    -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

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Re: Help with MS SQL Server Connection String

    great, thanks guys.

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