error of syntax

Discussion in 'Windows Forms' started by DN Admin, Apr 2, 2012.

  1. DN Admin

    Staff Member

    Joined:
    Aug 7, 2010
    Location:
    Joliet, IL U.S.A.
    using System;<br/>
    using System.Collections.Generic;<br/>
    using System.ComponentModel;<br/>
    using System.Data;<br/>
    using System.Drawing;<br/>
    using System.Text;<br/>
    using System.Windows.Forms;<br/>
    using MSTSCLib;<br/>
    using System.Data.SqlClient;<br/>
    using System.Data.OleDb;<br/>
    <br/>
    <br/>
    namespace SampleRDC<br/>
    {<br/>
    public partial class Form1 : Form<br/>
    {<br/>
    private OleDbConnection myCon;<br/>
    // string str = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersPrashantDesktopSampleRDCDatabase2.accdb;User Id=admin;Password=;";<br/>
    //string query;<br/>
    <br/>
    public Form1()<br/>
    {<br/>
    InitializeComponent();<br/>
    myCon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersPrashantDesktopSampleRDCDatabase2.accdb;User Id=admin;Password=;User Id=admin;Password=;");<br/>
    InitializeComponent();<br/>
    }<br/>
    <br/>
    <br/>
    <br/>
    <br/>
    private void button1_Click(object sender, EventArgs e)<br/>
    {<br/>
    try<br/>
    {<br/>
    OleDbCommand cmd = new OleDbCommand();<br/>
    myCon.Open();<br/>
    cmd.Connection = myCon;<br/>
    cmd.CommandType = CommandType.Text;<br/>
    cmd.CommandText="INSERT INTO Records(Server, UserName, Password) Values ('" + txtServer.Text + "' , '" + txtUserName.Text + "' , '" + txtPassword.Text + "')";<br/>
    <br/>
    <br/>
    <br/>
    <br/>
    cmd.ExecuteNonQuery();<br/>
    myCon.Close();<br/>
    }<br/>
    /*<br/>
    rdp.Server = txtServer.Text;<br/>
    rdp.UserName = txtUserName.Text;<br/>
    <br/>
    <br/>
    IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();<br/>
    secured.ClearTextPassword = txtPassword.Text;<br/>
    rdp.Connect();<br/>
    */<br/>
    <br/>
    catch (Exception Ex)<br/>
    {<br/>
    // MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);<br/>
    MessageBox.Show(Ex.Message);<br/>
    }<br/>
    }<br/>
    <br/>
    <br/>
    private void button2_Click(object sender, EventArgs e)<br/>
    {<br/>
    try<br/>
    {<br/>
    // Check if connected before disconnecting<br/>
    if (rdp.Connected.ToString() == "1")<br/>
    rdp.Disconnect();<br/>
    }<br/>
    catch (Exception Ex)<br/>
    {<br/>
    MessageBox.Show("Error Disconnecting", "Error disconnecting from remote desktop " + txtServer.Text + " Error: " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);<br/>
    }<br/>
    }<br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    }<br/>
    }

    View the full article
     
    #1

Share This Page