Click here to Skip to main content
15,886,640 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PD-JANAKAN is my server name....
my ip address is 172.21.1.91

if i put 172.21.1.91 apart of PD-JANAKAN
is it okay?

if i put 172.21.1.91
it ll say unhandled exception has occured in your application. the application will ignore this error and attempt to ontinur. if you click quit the application will close immediately

cannot open database "EnqInfo" requested by the login. the login failed. Login failed for user "Hemas\itcordinator.travels".

Hemas\itcordinator.travels = this mean the other computer which i goin to access the database from.


C#
private void Btn1_Click(object sender, EventArgs e)
        {
            string connetionString = null;

            //string sql = null;
            string name = "";
            string pass = "";

            connetionString = "Data Source=PD-JANAKAN;Initial Catalog=EnqInfo;Integrated Security=True";


            using (SqlConnection con = new SqlConnection(connetionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //
                using (SqlCommand command = new SqlCommand("SELECT * FROM Login WHERE U_Name=@Usr", con))
                    {

                        command.Parameters.AddWithValue("@Usr", UName.Text);
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            name = reader.GetString(1);  // Name string
                            pass = reader.GetString(2); // Password string
                        }

                        if (name == UName.Text && pass == PWord.Text)
                        {

                            ClassEnq.Uname = UName.Text;
                            MessageBox.Show("Password Accepted");
                            this.Close();
                            setEnableToolStripMenuItem(true);
                            setEnableToolStripMenuItem1(true);
                            setDisableToolStripMenuItem(false);

                        }

                        else
                        {
                            MessageBox.Show("Password Incorrect, Please Re-Enter Your Password");
                            setEnableToolStripMenuItem(false);
                            setEnableToolStripMenuItem1(false);
                        }
                    }
                }
Posted

Hi,
This means your Windows authentication user ID doesn't have access to the DB. You can login to the server via a common SQL authentication or try providing access to NT Authority System and get access to the Windows authentication.

Thanks & Regards,
Mathi.
 
Share this answer
 
Further to Solution 1 - I'm not convinced by your connection string - check out the details here ... https://www.connectionstrings.com/sql-server/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900