Hi ,
Please help with the code.
i want to connect to Remote desktop using C# and also connect to a database in a remote desktop and pull information and display it in a gridview control.
Here is my code but it times out.
private void button1_Click(object sender, EventArgs e)
{
try
{
rdp.Server = txtServer.Text;
rdp.UserName = txtUserName.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = txtPassword.Text;
rdp.Connect();
SqlConnection con=new SqlConnection(@"Server=blablabla;Database=blablabla;User Id=blablabla;Password=blablabla;");
if (con.State == ConnectionState.Closed)
{
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("select * from blablabla", con);
sda.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
catch (Exception Ex)
{
//MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + txtServer.Text + " Error: " + Ex.Message,MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Please help to correct this code
Thanks a lot