Вы находитесь на странице: 1из 51

1. Write a program to create a clone of an array.

using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace ConsoleApplication6 { classProgram { staticvoid Main(string[] args) { string[] name = {"Delhi", "Mumbai", "Chennai", "Calcutta"; string[] @Clone = (string[])name.Clone(); Console.WriteLine("\n The original array is:"); for (int i = 0; i <= name.GetUpperBound(0); i++) { Console.WriteLine(name[i]); } Console.WriteLine("\n The cloned array is:"); for (int i = 0; i <= name.GetUpperBound(0); i++) { Console.WriteLine(Clone[i]); } Console.ReadLine(); } } }

Output

2. Write a program to use array functions to sort and reverse a given array.
using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace ConsoleApplication6 { classProgram { staticvoid Main(string[] args) { string[] name = {"Delhi", "Mumbai", "Chennai", "Calcutta" }; string[] @Clone = (string[])name.Clone(); Console.WriteLine("\n The original array is:"); for (int i = 0; i <= name.GetUpperBound(0); i++) { Console.WriteLine(name[i]); }

Console.WriteLine("\n The sorted array is:"); System.Array.Sort(name); for (int i = 0; i <= name.GetUpperBound(0); i++) { Console.WriteLine(name[i]); }

Console.WriteLine("\n The reversed array is:"); System.Array.Reverse(Clone); for (int i = 0; i <= name.GetUpperBound(0); i++) { Console.WriteLine(Clone[i]);

Console.ReadLine(); } } }

Output

3. Write a program to implement a stack.

using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace ConsoleApplication6 { classProgram { staticvoid Main(string[] args) { Stack<Int32> USIT = newStack<Int32>(); for (int i = 0; i < 5; i++) USIT.Push(i * 5); Console.WriteLine("The stack is:\n"); PrintValues(USIT); Console.WriteLine("Now popping the first element:\n"); USIT.Pop(); PrintValues(USIT); Console.ReadLine(); } publicstaticvoidPrintValues(IEnumerable<Int32>myCollection) { IEnumerator<Int32> enumerator = myCollection.GetEnumerator(); while (enumerator.MoveNext()) Console.WriteLine("{0}", enumerator.Current); Console.WriteLine(); }

} }

Output

4. Write a program to implement a data dictionary.

using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace ConsoleApplication6 { classProgram { staticvoid Main(string[] args) { Dictionary<string, string>Dict = newDictionary<string, string>(); Dict.Add("021", Dict.Add("022", Dict.Add("023", Dict.Add("024", Dict.Add("028", Dict.Add("040", Dict.Add("041", Dict.Add("048", Dict.Add("049", Dict.Add("054", Dict.Add("055", Dict.Add("065", Dict.Add("066", "Aditya"); "Sandeep"); "Vasant"); "Piyush"); "Mayank"); "Shitiz"); "Raghav"); "Pinkesh"); "Yogesh"); "Salija"); "Deepak"); "Jitesh"); "Aditi");

Console.WriteLine("The person having a roll no. 55 is {0}. ", Dict["055"]); Console.ReadLine();

} }

Output

5. Write a program to create a simple GUI form and show the entered data in a message box.

5.1 Program.cs
using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace WindowsFormsApplication3 { staticclassProgram { ///<summary> ///The main entry point for the application. ///</summary> [STAThread] staticvoid Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(newForm1()); } } }

5.2 Form1.Designer.cs namespace WindowsFormsApplication3 { partialclassForm1 {

///<summary> ///Required designer variable. ///</summary> privateSystem.ComponentModel.IContainer components = null; ///<summary> /// Clean up any resources being used. ///</summary> ///<param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protectedoverridevoid Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code ///<summary> ///Required method for Designer support - do not modify /// the contents of this method with the code editor. ///</summary> privatevoidInitializeComponent() { this.txt1 = newSystem.Windows.Forms.TextBox(); this.lb1 = newSystem.Windows.Forms.Label(); this.lb2 = newSystem.Windows.Forms.Label(); this.txt2 = newSystem.Windows.Forms.TextBox(); this.bt = newSystem.Windows.Forms.Button(); this.SuspendLayout(); // // txt1 // this.txt1.Location = newSystem.Drawing.Point(124, 42); this.txt1.Name = "txt1"; this.txt1.Size = newSystem.Drawing.Size(100, 20); this.txt1.TabIndex = 0; // // lb1 // this.lb1.AutoSize = true; this.lb1.Location = newSystem.Drawing.Point(28, 49); this.lb1.Name = "lb1";

this.lb1.Size = newSystem.Drawing.Size(35, 13); this.lb1.TabIndex = 1; this.lb1.Text = "Name"; // // lb2 // this.lb2.AutoSize = true; this.lb2.Location = newSystem.Drawing.Point(28, 87); this.lb2.Name = "lb2"; // this.lb2.Size = new System.Drawing.Size(53, 13); this.lb2.TabIndex = 2; this.lb2.Text = "Password"; // // txt2 // this.txt2.Location = newSystem.Drawing.Point(124, 80); this.txt2.Name = "txt2"; this.txt2.Size = newSystem.Drawing.Size(100, 20); this.txt2.TabIndex = 3; this.txt2.UseSystemPasswordChar = true; // // bt // this.bt.Location = newSystem.Drawing.Point(82, 155); this.bt.Name = "bt"; this.bt.Size = newSystem.Drawing.Size(75, 23); this.bt.TabIndex = 4; this.bt.Text = "Show"; this.bt.UseVisualStyleBackColor = true; this.bt.Click += newSystem.EventHandler(this.bt_Click); // // Form1 // this.AutoScaleDimensions = newSystem.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = newSystem.Drawing.Size(259, 236); this.Controls.Add(this.bt); this.Controls.Add(this.txt2); this.Controls.Add(this.lb2); this.Controls.Add(this.lb1); this.Controls.Add(this.txt1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout();

} #endregion privateSystem.Windows.Forms.TextBox txt1; privateSystem.Windows.Forms.Label lb1; privateSystem.Windows.Forms.Label lb2; privateSystem.Windows.Forms.TextBox txt2; privateSystem.Windows.Forms.Buttonbt; } }

5.3 Form1.cs using System; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing;

usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace WindowsFormsApplication3 { publicpartialclassForm1 : Form { public Form1() { InitializeComponent(); } privatevoidbt_Click(object sender, EventArgs e) { stringvar = "Name is "+txt1.Text+'\n'; string var1 = "Password is"+txt2.Text; MessageBox.Show(var+var1, "Output"); } } }

Output

6. Write a program to design a GUI form for employee details.

6.1 Program.cs
using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace WindowsFormsApplication8 { staticclassProgram { ///<summary> ///The main entry point for the application. ///</summary> [STAThread] staticvoid Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(newForm1()); } } }

6.2 Form1.Designer.cs

namespace WindowsFormsApplication8 {

partialclassForm1 { ///<summary> ///Required designer variable. ///</summary> privateSystem.ComponentModel.IContainer components = null; ///<summary> /// Clean up any resources being used. ///</summary> ///<param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protectedoverridevoid Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code ///<summary> ///Required method for Designer support - do not modify /// the contents of this method with the code editor. ///</summary> privatevoidInitializeComponent() { this.textBox1 = newSystem.Windows.Forms.TextBox(); this.textBox2 = newSystem.Windows.Forms.TextBox(); this.label1 = newSystem.Windows.Forms.Label(); this.label2 = newSystem.Windows.Forms.Label(); this.label3 = newSystem.Windows.Forms.Label(); this.textBox3 = newSystem.Windows.Forms.TextBox(); this.label4 = newSystem.Windows.Forms.Label(); this.label5 = newSystem.Windows.Forms.Label(); this.listBox1 = newSystem.Windows.Forms.ListBox(); this.button1 = newSystem.Windows.Forms.Button(); this.textBox4 = newSystem.Windows.Forms.TextBox(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = newSystem.Drawing.Point(266, 72); this.textBox1.Name = "textBox1";

this.textBox1.Size = newSystem.Drawing.Size(193, 20); this.textBox1.TabIndex = 0; // // textBox2 // this.textBox2.Location = newSystem.Drawing.Point(266, 129); this.textBox2.Name = "textBox2"; this.textBox2.Size = newSystem.Drawing.Size(193, 20); this.textBox2.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = newSystem.Drawing.Point(108, 392); this.label1.Name = "label1"; this.label1.Size = newSystem.Drawing.Size(63, 13); this.label1.TabIndex = 2; this.label1.Text = "Designation"; // // label2 // this.label2.AutoSize = true; this.label2.Location = newSystem.Drawing.Point(108, 79); this.label2.Name = "label2"; this.label2.Size = newSystem.Drawing.Size(70, 13); this.label2.TabIndex = 3; this.label2.Text = "Employee ID"; // // label3 // this.label3.AutoSize = true; this.label3.Location = newSystem.Drawing.Point(108, 132); this.label3.Name = "label3"; this.label3.Size = newSystem.Drawing.Size(35, 13); this.label3.TabIndex = 4; this.label3.Text = "Name"; // // textBox3 // this.textBox3.Location = newSystem.Drawing.Point(266, 190); this.textBox3.Multiline = true; this.textBox3.Name = "textBox3"; this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textBox3.Size = newSystem.Drawing.Size(193, 75); this.textBox3.TabIndex = 5; //

// label4 // this.label4.AutoSize = true; this.label4.Location = newSystem.Drawing.Point(108, 190); this.label4.Name = "label4"; this.label4.Size = newSystem.Drawing.Size(45, 13); this.label4.TabIndex = 6; this.label4.Text = "Address"; // // label5 // this.label5.AutoSize = true; this.label5.Location = newSystem.Drawing.Point(108, 313); this.label5.Name = "label5"; this.label5.Size = newSystem.Drawing.Size(81, 13); this.label5.TabIndex = 9; this.label5.Text = "Gender (F or M)"; // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.Items.AddRange(newobject[] { "president", "vice-President", "CFO", "manager", "director", "supervisor"}); this.listBox1.Location = newSystem.Drawing.Point(266, 392); this.listBox1.Name = "listBox1"; this.listBox1.Size = newSystem.Drawing.Size(114, 82); this.listBox1.TabIndex = 10; // // button1 // this.button1.Location = newSystem.Drawing.Point(198, 539); this.button1.Name = "button1"; this.button1.Size = newSystem.Drawing.Size(75, 23); this.button1.TabIndex = 11; this.button1.Text = "Submit"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += newSystem.EventHandler(this.button1_Click); // // textBox4 // this.textBox4.Location = newSystem.Drawing.Point(266, 310);

this.textBox4.Name = "textBox4"; this.textBox4.Size = newSystem.Drawing.Size(45, 20); this.textBox4.TabIndex = 12; // // Form1 // this.AutoScaleDimensions = newSystem.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = newSystem.Drawing.Size(510, 568); this.Controls.Add(this.textBox4); this.Controls.Add(this.button1); this.Controls.Add(this.listBox1); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.textBox3); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); } #endregion privateSystem.Windows.Forms.TextBox textBox1; privateSystem.Windows.Forms.TextBox textBox2; privateSystem.Windows.Forms.Label label1; privateSystem.Windows.Forms.Label label2; privateSystem.Windows.Forms.Label label3; privateSystem.Windows.Forms.TextBox textBox3; privateSystem.Windows.Forms.Label label4; privateSystem.Windows.Forms.Label label5; privateSystem.Windows.Forms.ListBox listBox1; privateSystem.Windows.Forms.Button button1; privateSystem.Windows.Forms.TextBox textBox4; } }

6.3 Form1.cs

using System; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace WindowsFormsApplication8 { publicpartialclassForm1 : Form

{ public Form1() { InitializeComponent(); } privatevoid button1_Click(object sender, EventArgs e) { string v1, v2; if (textBox4.Text.Equals('F')) { v1 = "Ms."; v2 = "She"; } else { v1 = "Mr."; v2 = "He"; }

string v3 = v1 + " " + textBox2.Text + " with ID " + textBox1.Text + " is a " + listBox1.Text + " in the company." + " " + v2 + " lives at " + textBox3.Text+"."; MessageBox.Show(v3, "Employee details"); }}}

Output

7. Write a program to display all the data providers.


using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text;

usingSystem.Threading.Tasks; usingSystem.Data; usingSystem.Data.OleDb; usingSystem.Data.Common; namespace ConsoleApplication8 { classProgram { staticvoid Main(string[] args) { DataTable providers = DbProviderFactories.GetFactoryClasses(); Console.WriteLine("List of the avilable ADO data providers:\n"); foreach (DataRowprovinproviders.Rows) { Console.WriteLine("Name: {0}", prov["Name"]); Console.WriteLine("Description: {0}", prov["Description"]); Console.WriteLine("Invariant name: {0}", prov["InvariantName"]); Console.WriteLine(); } Console.ReadLine();

} } }

Output

8. Write a program to display the connection details.


using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Data; usingSystem.Data.OleDb;

namespace ConsoleApplication7 { classProgram { staticvoid Main(string[] args) { stringconnectionstring = "Provider=Microsoft.Ace.OleDb.12.0;Data Source = C:\\Database1.accdb;"; OleDbConnection connection = newOleDbConnection(connectionstring); try { connection.Open(); Console.WriteLine("Connection State: {0}", connection.State); Console.WriteLine("OleDbproviderL {0}", connection.Provider); Console.WriteLine("Server version: {0}", connection.ServerVersion); Console.WriteLine("Data Souurce: {0}", connection.DataSource); Console.WriteLine("Connection Site: {0}", connection.Site); Console.WriteLine("Connection Timeout: {0}", connection.ConnectionTimeout); Console.WriteLine("Connection String: {0}", connection.ConnectionString); } catch (DataException e) { Console.WriteLine(e.ToString()); } finally { connection.Close(); } Console.ReadLine();

} }}

Output

9. Write a program to connect Microsoft access database by using OleDb.


using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks;

usingSystem.Data; usingSystem.Data.OleDb; namespace ConsoleApplication7 { classProgram { staticvoid Main(string[] args) { stringconnectionstring = "Provider=Microsoft.Ace.OleDb.12.0;Data Source = C:\\Database1.accdb;"; OleDbConnection connection = newOleDbConnection(connectionstring); try { connection.Open(); stringsql = @"select * from EMP where EAge='22'"; OleDbCommandcmd = newOleDbCommand(sql, connection); OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine("EMP Console.WriteLine("EMP Console.WriteLine("EMP Console.WriteLine("EMP Console.WriteLine("EMP Console.WriteLine("EMP } } catch (DataException e) { Console.WriteLine(e.ToString()); } ID is {0}", reader[0]); Name is {0}", reader[1]); Age is {0}", reader[2]); Phone no. is {0}", reader[3]); Designation is {0}", reader[4]); City is {0}", reader[5]);

finally {

connection.Close(); } Console.ReadLine(); }

} }

Database table

Output

10. Write a program to create a connection with the SQL Server and show and update the database entries.

using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Data; usingSystem.Data.SqlClient; namespace ConsoleApplication7 { classProgram { staticvoid Main(string[] args) { stringconnectionstring = @"Data Source=(localdb)\\Projects;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"; SqlConnection connection = newSqlConnection(connectionstring); try { connection.Open(); stringsql = @"select * from EMP"; SqlCommandcmd = newSqlCommand(sql, connection);

SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine("EMP ID is {0}", reader[0]); Console.WriteLine("EMP Name is {0}", reader[1]); Console.WriteLine("EMP City is {0}", reader[2]); } } catch (DataException e) { Console.WriteLine(e.ToString()); }

finally { connection.Close(); } Console.ReadLine(); }

} }

Database table

Output

11. Write a program to create a log-in form in ASP.


<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs "Inherits="WebApplication2.WebForm1"%> <scriptrunat="server"> privatevoid Login(object sender, EventArgs e) { stringuid = ID.Value;

stringpwd = Pswd.Value; string str1; if (uid.Equals("USICT")) { str1 = "valid"; } else { str1 = "invalid"; } A.InnerText = "The info about logged in employee is " + uid + " and is " + str1 + ". His Password is " +pwd; } </script> <!DOCTYPEhtml> <htmlxmlns="http://www.w3.org/1999/xhtml"> <headid="Head1"runat="server"> <title>Login Please</title> </head> <body> <formid="form1"runat="server"> UserID:&nbsp;&nbsp;&nbsp;&nbsp;<inputrunat="server"id="ID"type="text"/ ><br/> Password: <inputrunat="server"id="Pswd"type="password"/> <inputrunat="server"id="Button1"type="submit"value="Submit"onservercli ck="Login"/> <hr> <h3>Employee Login Details:</h3> <spanrunat="server"id="A"/>

</form> </body> </html>

Output

12. Write a program to connect Microsoft access database via ASP by using DSN.
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs "Inherits="WebApplication2.WebForm1"%> <%@ImportNamespace="System"%> <%@ImportNamespace="System.Data"%> <%@ImportNamespace="System.Data.Odbc"%>

<scriptrunat="server"> voidPage_Load (Object sender, EventArgs e) { StringconnectString = "DSN=USIT;Uid=' ';Pwd=' '"; OdbcConnectionmyConn = null; try { myConn = newOdbcConnection( connectString ); myConn.Open(); lblConnectInfo.Text = "Connection successful!.....CONNECTED TO ACCESSS"; } catch { lblConnectInfo.Text = "Connection failed!"; } finally { if (myConn != null) myConn.Close(); } } </script> <html> <head> <title></title> </head> <body> <formid="form1"method="post"runat="server"> Opening an ODBC connection. <asp:Labelid="lblConnectInfo"runat="server"></asp:Label> </form> </body> </html>

Output

13. Write a program to connect Microsoft access database via ASP by using data provider and show the content.
<%@ImportNamespace="System.Data"%> <%@ImportNamespace="System.Data.OleDb"%> <%@ImportNamespace="System"%> <%@ImportNamespace="System.Text"%> <scriptLanguage="c#"runat="server">

voidPage_Load() { stringstrConnection = "Provider=Microsoft.Ace.OleDb.12.0; "; strConnection += @"Data Source = C:\Database1.mdb;"; data_src.Text = strConnection; stringstrSQL = "SELECT * FROM EMP;"; DataSetobjDataSet = newDataSet(); OleDbConnectionobjConnection = newOleDbConnection(strConnection); OleDbDataAdapterobjAdapter = newOleDbDataAdapter(strSQL, objConnection); objAdapter.Fill(objDataSet, "Employee"); DataViewobjDataView = newDataView(objDataSet.Tables[0]); dgNameList.DataSource=objDataView; dgNameList.DataBind(); } </script> <html> <body> <h4>Reading data from the connection <asp:labelid="data_src"runat="server"/> to the DataGrid control.</h4> <asp:datagridid="dgNameList"runat="server"/><br/> </body> </html>

Output

14. Write a program to connect SQL Server via ASP.


<%@ImportNamespace="System.Data"%> <%@ImportNamespace="System.Data.SqlClient"%> <scriptLanguage="c#"runat="server"> voidPage_Load() {

stringstrConnection = "Data Source=(localdb)\\Projects;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"; data_src.Text = "The Connection String is"+strConnection; SqlConnectionobjConnection = newSqlConnection(strConnection); try { objConnection.Open(); con_open.Text="Connection opened successfully.<br />"; objConnection.Close(); con_close.Text="Connection closed.<br />"; } catch (Exception e) { con_open.Text="Connection failed to open.<br />"; con_close.Text=e.ToString(); } } </script> <html> <body> <h4>Testing the data connection <asp:labelid="data_src"runat="server"/></h4> <asp:labelid="con_open"runat="server"/><br/> <asp:labelid="con_close"runat="server"/><br/> </body> </html>

Output

15. Write a program to connect SQL Server via ASP and search and show the record.
<%@ImportNamespace="System.Data"%> <%@ImportNamespace="System.Data.SqlClient"%>

<scriptLanguage="c#"runat="server"> voidPage_Load() { SqlConnectionsqlConnection; SqlDataAdaptersqlDataAdapter; SqlCommandsqlCommand; DataSetdataSet; DataTabledataTable;

if (IsPostBack) { try{ stringstrConnection = "Data Source=(localdb)\\Projects;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"; sqlConnection = newSqlConnection(strConnection); stringsqlQuery = @"Select * from EMP"; sqlCommand = newSqlCommand(sqlQuery, sqlConnection); sqlDataAdapter = newSqlDataAdapter( sqlCommand ); dataSet = newDataSet(); sqlDataAdapter.Fill(dataSet, "EMP"); DataColumn[] pkColumn = newDataColumn[1]; pkColumn[0] = dataSet.Tables[0].Columns["EID"]; dataSet.Tables[0].PrimaryKey = pkColumn; DataRowrowFound = dataSet.Tables[0].Rows.Find(IdTextBox.Text); if (rowFound == null) { msgLabel.Text = "The Employee ID entered was not found."; } else { StringBuilderstringBuilder = newStringBuilder("Employee\t"); stringBuilder.Append(rowFound["EID"].ToString()); stringBuilder.Append(", "); stringBuilder.Append(rowFound["EName"].ToString());

stringBuilder.Append(" at "); stringBuilder.Append(rowFound["ECity"].ToString()); msgLabel.Text = stringBuilder.ToString(); } } catch (Exception exception) { msgLabel.Text = exception.ToString(); } } } </script> <html> <head> <title>Finding a Particular Row in a DataSet</title> </head> <body> <formid="form1"method="post"runat="server"> <asp:labelid="customerIdLabel"runat="server">Employee ID:</asp:label> <asp:textboxid="IdTextBox"runat="server"></asp:textbox> <asp:buttonid="findButton"runat="server"Text="Find"></asp:button><br> <asp:labelid="msgLabel"runat="server"></asp:label></form> </body> </html>

Output

Вам также может понравиться