skip to main |
skip to sidebar
RSS Feeds
Now maintained at http://www.prithviraj.com.np
Now maintained at http://www.prithviraj.com.np
Sunday, October 21, 2012
By Unknown
comboBox2.Items.Clear(); if (checkBox1.Checked == true) { ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;"; } else { ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";"; } SqlConnection Conexion = new SqlConnection(ConStr); Conexion.Open(); label9.Visible = false; panel2.Visible = false; button2.Visible = true; panel1.Visible = true; groupBox1.Visible = true; DataTable tblDatabases = Conexion.GetSchema("Databases"); for (int i = 0; i <= tblDatabases.Rows.Count - 1; i++) { comboBox2.Items.Add(tblDatabases.Rows[i][0].ToString()); } Conexion.Close();
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { comboBox3.Items.Clear(); SqlConnection conx = new SqlConnection(ConStr + "Database ="+comboBox2.Text.ToString()+";"); conx.Open(); DataTable tblTables = conx.GetSchema("Tables"); for (int i = 0; i <= tblTables.Rows.Count - 1; i++) { comboBox3.Items.Add(tblTables.Rows[i][2].ToString()); } conx.Close(); }Here we are creating Connection String Everytime, because, It is changing every-time. Now this code will list all the Tables inside Database in Table Combo (combobox3): Code:
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { comboBox4.Items.Clear(); SqlConnection conx = new SqlConnection(ConStr + "Database =" + comboBox2.Text.ToString() + ";"); conx.Open(); string tableName = comboBox3.SelectedItem.ToString(); SqlDataAdapter adp = new SqlDataAdapter("select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '"+comboBox3.SelectedItem.ToString()+"'",conx); DataTable tblColumns = new DataTable(); adp.Fill(tblColumns); for (int i = 0; i <= tblColumns.Rows.Count - 1; i++) { comboBox4.Items.Add(tblColumns.Rows[i][3].ToString()); } conx.Close(); }
private void textBox3_TextChanged(object sender, EventArgs e) { string QueryCon = ConStr; if (comboBox5.Text.ToString() == "like") { QueryStr = "SELECT * FROM " + comboBox3.Text.ToString() + " WHERE " + comboBox4.Text.ToString() + " " + comboBox5.Text.ToString() + " '%" + textBox3.Text + "%'"; } else { QueryStr = "SELECT * FROM " + comboBox3.Text.ToString() + " WHERE " + comboBox4.Text.ToString() + " " + comboBox5.Text.ToString() + " '" + textBox3.Text + "'"; } TxtQueryBox.Text = ConStr + "Database=" + comboBox2.Text.ToString() + ";"+"\n" + QueryStr; SqlDataAdapter adp = new SqlDataAdapter(QueryStr, ConStr+"Database="+comboBox2.Text.ToString()+";"); DataSet ds = new DataSet(); adp.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; }
Wednesday, October 10, 2012
By Anonymous
using System.Data.Sql; using System.Data.SqlClient;
private void Form1_Load(object sender, EventArgs e) { panel1.Visible = false; groupBox1.Visible = false; label9.Visible = true; label9.TextAlign = ContentAlignment.MiddleCenter; SqlDataSourceEnumerator SerInstances = SqlDataSourceEnumerator.Instance; DataTable SerNames = SerInstances.GetDataSources(); for (int i = 0; i <= SerNames.Rows.Count - 1; i++) { comboBox1.Items.Add(SerNames.Rows[i][0].ToString()+"\\"+SerNames.Rows[i][1].ToString()); } }
private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked == true && textBox1.Text.Trim().Length > 0) { MessageBox.Show("Please Uncheck Integrated Security or Clear UserName!", this.Text + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (checkBox1.Checked == false && textBox1.Text.Trim().Length == 0) { MessageBox.Show("Please Check Integrated Security or Enter UserName!", this.Text + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBox1.Text.Trim().Length > 0 && textBox2.Text.Trim().Length == 0) { errorProvider1.SetError(textBox2, "Please enter password for Username = " + textBox1.Text + "!"); } else if (comboBox1.Text.Trim().Length == 0) { MessageBox.Show("Please select Server from List. If You can not see any Instance in Servers Combobox, Contact your Network Administrator!", this.Text + " - Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { errorProvider1.Clear(); if (MessageBox.Show("Connection Successfull!, You are Now Connected to Server: " + comboBox1.Text.ToString() + "!", this.Text + " - Alert", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { comboBox2.Items.Clear(); if (checkBox1.Checked == true) { ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;"; } else { ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";"; } SqlConnection Conexion = new SqlConnection(ConStr); Conexion.Open(); label9.Visible = false; panel2.Visible = false; button2.Visible = true; panel1.Visible = true; groupBox1.Visible = true; DataTable tblDatabases = Conexion.GetSchema("Databases"); for (int i = 0; i <= tblDatabases.Rows.Count - 1; i++) { comboBox2.Items.Add(tblDatabases.Rows[i][0].ToString()); } Conexion.Close(); } } }
Sunday, October 07, 2012
By Unknown
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Accordian with CSS >> P.Yar.B Complex</title> <%--<link href="Accordian.css" rel="stylesheet" />--%> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table width="100%" border="0"> <tr> <td colspan="2" align="center"> <h1>Accordian with CSS</h1> </td> </tr> <tr> <td colspan="3" align="center"> <asp:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="490px"> <Panes> <asp:AccordionPane ID="pane1" runat="server"> <Header>Hardwares</Header> <Content> Mouse<br /> KeyBoard<br /> Monitor <br /> Printer<br /> CPU<br /> Speakers<br /> Camera </Content> </asp:AccordionPane> <asp:AccordionPane ID="pane2" runat="server"> <Header>Operating System</Header> <Content> MS Windows<br /> Linux<br /> Android<br /> Mac<br /> Unix </Content> </asp:AccordionPane> <asp:AccordionPane ID="pane3" runat="server"> <Header>.NET IDE</Header> <Content> Visual Studio<br /> Visual Web Developer<br /> SharpDevelop<br /> MonoDevelop </Content> </asp:AccordionPane> <asp:AccordionPane ID="pane4" runat="server"> <Header>John Bhatt</Header> <Content> <a href="http://www.johnbhatt.com" target="_blank">Portal Home</a><br /> <a href="http://blog.johnbhatt.com" target="_blank">Blog of P.Yar.B</a><br /> <a href="http://media.johnbhatt.com" target="_blank">Download Center</a><br /> </Content> </asp:AccordionPane> </Panes> </asp:Accordion> </td> </tr> </table> </form> </body> </html>
.accordionHeader { border: 1px solid #2F4F4F; color: white; background-color: #2E4d7B; font-family: Arial, Sans-Serif; font-size: 12px; font-weight: bold; padding: 5px; margin-top: 5px; cursor: pointer; } #master_content .accordionHeader a { color: #FFFFFF; background: none; text-decoration: none; } #master_content .accordionHeader a:hover { background: none; text-decoration: underline; } .accordionHeaderSelected { border: 1px solid #2F4F4F; color: white; background-color: #5078B3; font-family: Arial, Sans-Serif; font-size: 12px; font-weight: bold; padding: 5px; margin-top: 5px; cursor: pointer; } #master_content .accordionHeaderSelected a { color: #FFFFFF; background: none; text-decoration: none; } #master_content .accordionHeaderSelected a:hover { background: none; text-decoration: underline; } .accordionContent { background-color: #D3DEEF; border: 1px dashed #2F4F4F; border-top: none; padding: 5px; padding-top: 10px; }Now Run the Page again. Lets See, how it looked.