what am i doing wrong here?

public int organization()
        string con = "Data Source=sasql01;Initial Catalog=sandbox;Trusted_Connection=true;Persist Security Info=True;User ID=sa_sql;Password=str@teg1K@m3r1ka";
        SqlConnection conn = new SqlConnection(con);
        string fetch = "Select SMP_Media_Type_Desc from Scores";
        SqlCommand cmd = new SqlCommand(fetch, conn);
        SqlDataReader sdr = null;
        sdr = cmd.ExecuteReader();
        string organization = string.Empty;
        while (sdr.Read())
            organization = sdr[0].ToString();

        return Convert.ToInt32(organization);

I am not able to open up the connection. The error: Login failed. The user is not associated with the trusted connection.
Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Trusted_Connection=true; implies that the login is a windows user account so it is trying to login with the current windows user details rather than the User ID and password you are supplying.

Remove the Trusted_Connection=true; option and see what happens.
siddhuoopsAuthor Commented:
That worked but as soon as I clicked on to go to the next page, the same problem interrupted the program.
siddhuoopsAuthor Commented:
Part of the problem is with the rest of the program. At least I knew what was wrong with this code. Thank you very much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.