i have created an application. and i have network linked machines as well.
so i want to access the database from another network machine.
so i have created an application and i want to access in another pc?
so how can i do that?
string connetionString = null;
string name = "";
string pass = "";
connetionString = "Data Source=172.21.1.91,1433;Initial Catalog=EnqInfo;Integrated Security=True";
using (SqlConnection con = new SqlConnection(connetionString))
{
con.Open();
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);
pass = reader.GetString(2);
}
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);
}
}
so i have assigned my ip address and port number to data source.
but it gives me an error saying,
unhandled exception has occurred in your application. if you click continue, the application will ignore this error and attemp to continue...... etc
A network related or instance-specific error occured while establishing a connection to sql server. the server was not found or was not accecible.
when i change datasource to my pc name, it will only work on my pc only.
so how can do that?