Sunday, March 9, 2008

management studio creation in windows application

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=Registration;Integrated Security=True");
SqlCommand cmd;
SqlDataReader dr;
DataTable dt = new DataTable();
private void btnexecute_Click(object sender, EventArgs e)
{



con.Open();
cmd = new SqlCommand(richTextBox1.Text, con);
dr = cmd.ExecuteReader();
dt.Load(dr);
dataGrid1.DataSource = dt;
cmd = new SqlCommand("sp_helpdb", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
treeView1.Nodes.Add(dr["name"].ToString());
}
dr.Close();
cmd = new SqlCommand("sp_helpdb", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
cboDb.Items.Add(dr["name"].ToString());
}
dr.Close();

}

private void newToolStripMenuItem_Click(object sender, EventArgs e)
{

}

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.Filter="Text File(*.txt)|*.txt";
string filename;
if(openFileDialog1.ShowDialog()==DialogResult.OK);
{
filename=openFileDialog1.FileName;
richTextBox1.LoadFile(openFileDialog1.FileName);

}

}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.Filter = "Text File(*.txt)|*.txt";
saveFileDialog1.DefaultExt = "*.txt";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox1.SaveFile(saveFileDialog1.FileName);
richTextBox1.Clear();
}
}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{

}

private void cboDb_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("use"+cboDb.Text,con);
dr = cmd.ExecuteReader();
dr.Close();

}
}
}

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...