Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

My connection string does not connect when using username and password - SQL (Urgent)

Posted on 2016-08-02
7
Medium Priority
?
54 Views
Last Modified: 2016-08-06
Hi

We have just replaced the server at a client and I am now trying to get my software to connect to the SQL database.

The connection string for the previous server was:

data source=MYSERVERNAME;initial catalog=dbHCA;persist security info=True;user id=myuser;password=mypassword;MultipleActiveResultSets=True;

This returns an error login failed for user 'myuser'.
Server authentication is set to both SQL and Windows

My user uses SQL server authentication and is mapped to dbHCA as a db_owner.
The properties look exactly the same as the previous server.

Am I missing something?

I did not setup the SQL server and we are using SQL server 2016.
Please let me know if you require more information.

As a side note: I can connect using integrated security
Data Source=MYSERVERNAME;Initial Catalog=dbHCA;Integrated Security=True
0
Comment
Question by:elmbrook
  • 4
  • 2
7 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 41738562
>>Am I missing something?

try to reset the password and use that new password in your connection string and try again?
0
 

Author Comment

by:elmbrook
ID: 41738565
Thank you for your reply.
That didn't work.
0
 
LVL 54

Assisted Solution

by:Ryan Chong
Ryan Chong earned 2000 total points
ID: 41738566
so, whats the error message you receiving now? are you connecting to the correct server?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:elmbrook
ID: 41738570
The error message is still the same.
login failed for user 'myuser'.

I am connected to the new server.
I have written a quick programme to test connection strings to the server (see code below)

this connection string connects
Data Source=MYSERVERNAME;Initial Catalog=dbHCA;Integrated Security=True
which tells me that I can connect to the server using Windows Authentication

this connection string
data source=MYSERVERNAME\;initial catalog=dbHCA;persist security info=True;user id=myuser;password=mynewpassword;MultipleActiveResultSets=True;
gives me the error which tells me SQL authentication is not working.

  private void button1_Click(object sender, EventArgs e)
        {
            string txt = textBox1.Text.Trim();
            SqlConnection thisConnection = null;
            thisConnection = new SqlConnection(string.Format( txt));

            try
            {
                thisConnection.Open();
                MessageBox.Show("Connected");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            textBox1.Text = "";
        }

Open in new window

0
 

Accepted Solution

by:
elmbrook earned 0 total points
ID: 41738580
Oh man...I've been working on this for hours.
Finally, I followed Microsoft's Mantra - 'If all else fails...reboot' and guess what.
It works now...I am unsure why it never worked in the first place but thanks for your input.
0
 
LVL 27

Expert Comment

by:Zberteoc
ID: 41739153
data source=MYSERVERNAME;initial catalog=dbHCA;persist security info=True;user id=myuser;password=mypassword;MultipleActiveResultSets=True;

I would remover "persist security info=True;" part.
0
 

Author Closing Comment

by:elmbrook
ID: 41745365
Reboot worked...Thanks for the help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question