Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
3
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.Diagnostics; using System.Data.SqlClient; namespace SQLBackUpApp { public partial class Form1 : Form { SqlConnection con; SqlCommand cmd; SqlDataReader dr; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { label3.Visible = false; serverName("."); } public void serverName(string str) { con = new SqlConnection("Data Source=" + str + ";Database=Master;data source=.; uid=sa; pwd=Micr0s0ft;"); con.Open(); cmd = new SqlCommand("select * from sysservers where srvproduct='SQL Server'", con); dr = cmd.ExecuteReader(); while (dr.Read()) { ComboBoxserverName.Items.Add(dr[2]); } dr.Close(); } public void Createconnection() { con = new SqlConnection("Data Source=" + (ComboBoxserverName.Text) + ";Database=Master;data source=.; uid=sa; pwd=Micr0s0ft;"); con.Open(); ComboBoxDatabaseName.Items.Clear(); cmd = new SqlCommand("select * from sysdatabases", con); dr = cmd.ExecuteReader(); while(dr.Read()) { ComboBoxDatabaseName.Items.Add(dr[0]); } dr.Close(); } public void query(string que) { // ERROR: Not supported in C#: OnErrorStatement cmd = new SqlCommand(que, con); cmd.ExecuteNonQuery(); } public void blank(string str) { if (string.IsNullOrEmpty(ComboBoxserverName.Text) | string.IsNullOrEmpty(ComboBoxDatabaseName.Text)) { // label3.Visible = true; MessageBox .Show( "Server Name & Database can not be Blank"); return; } else { if (str == "backup") { SaveFileDialog1.FileName = ComboBoxDatabaseName.Text; SaveFileDialog1.ShowDialog(); string s = null; s = SaveFileDialog1.FileName; query("Backup database " + ComboBoxDatabaseName.Text + " to disk='" + s + "'"); label3.Visible = true; label3.Text = "Database BackUp has been created successful"; } } } private void cmbbackup_Click(object sender, EventArgs e) { blank("backup"); } private void cmbserver_SelectedIndexChanged(object sender, EventArgs e) { Createconnection(); } } }
run
|
edit
|
history
|
help
0
learning1
Robot_Testing
Code which will convert Word into its Binary Format
Least Common Multiple of 2 or more numbers.
Staircase
my cool stuff
Project Euler Problem 4
saxasd
array integration
EMV_RESULTAT