using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MSTSCLib;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace SampleRDC
{
public partial class Form1 : Form
{
private OleDbConnection myCon;
// string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersPrashantDesktopSampleRDCDatabase2.accdb;User Id=admin;Password=;";
//string query;
public Form1()
{
InitializeComponent();
myCon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersPrashantDesktopSampleRDCDatabase2.accdb;User Id=admin;Password=;User Id=admin;Password=;");
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
OleDbCommand cmd = new OleDbCommand();
myCon.Open();
cmd.Connection = myCon;
cmd.CommandType = CommandType.Text;
cmd.CommandText="INSERT INTO Records(Server, UserName, Password) Values ('" + txtServer.Text + "' , '" + txtUserName.Text + "' , '" + txtPassword.Text + "')";
cmd.ExecuteNonQuery();
myCon.Close();
}
/*
rdp.Server = txtServer.Text;
rdp.UserName = txtUserName.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = txtPassword.Text;
rdp.Connect();
*/
catch (Exception Ex)
{
// MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(Ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
// Check if connected before disconnecting
if (rdp.Connected.ToString() == "1")
rdp.Disconnect();
}
catch (Exception Ex)
{
MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
View the full article
No replies to this topic
#1
Posted 02 April 2012 - 11:10 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users




Sign In
Create Account
Back to top







