SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
Studb.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace student
{
public class studb
{
public string getId(string sqlquery, SqlConnection connectionstring, ComboBox combox1)
{
DataSet ds = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter(sqlquery, connectionstring);
adap.Fill(ds, "student");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
combox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
return null;
}
public string add(string id, string name, string dept, string phone, SqlConnection
connectionstring)
{
string sqlquery = "insert into student(id,name,dept,phone) values ('" + id + "','" + name + "','" +
dept + "','" + phone + "')";
SqlCommand cmd = new SqlCommand(sqlquery,connectionstring );
//connectionstring.Open();
try
{
cmd.ExecuteNonQuery();
MessageBox.Show("Inserted");
}
catch (Exception e)
{
MessageBox.Show("not inserted");
}
return null;
}
public string showgrid(string sqlquery, SqlConnection connectionstring, DataGridView
grid1)
{
DataSet ds = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter(sqlquery, connectionstring);
adap.Fill(ds, "student");
grid1.DataSource = ds;
grid1.DataMember = "student";
return null;
}
}
}
************************
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using student;
using System.Data.SqlClient;
namespace college
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con.ConnectionString = @"Data
Source=(LocalDB)v11.0;AttachDbFilename=E:c#studentstudentCollege.mdf;Integrated
Security=True";
con.Open();
string sqlquery = "select id from student";
studb st = new studb();
st.getId(sqlquery, con, comboBox1);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string sqlquery = "Select * from student where id='"+comboBox1.Text +"'";
studb st = new studb();
st.showgrid(sqlquery, con, dataGridView1);
}
private void button1_Click(object sender, EventArgs e)
{
studb st = new studb();
st.add(textBox1.Text, textBox2.Text, textBox3.Text,textBox4.Text, con);
}
private void Exit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
How to Create Database component -Enterprise Application Using C# Lab

Mais conteúdo relacionado

Mais procurados

Laporan Resmi Algoritma dan Struktur Data :
Laporan Resmi Algoritma dan Struktur Data : Laporan Resmi Algoritma dan Struktur Data :
Laporan Resmi Algoritma dan Struktur Data :
Siska Amelia
 

Mais procurados (20)

Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>Java Foundations: Lists, ArrayList<T>
Java Foundations: Lists, ArrayList<T>
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
 
Collections generic
Collections genericCollections generic
Collections generic
 
Collection
CollectionCollection
Collection
 
Procedural Content Generation with Clojure
Procedural Content Generation with ClojureProcedural Content Generation with Clojure
Procedural Content Generation with Clojure
 
Functional Programming, simplified
Functional Programming, simplifiedFunctional Programming, simplified
Functional Programming, simplified
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCJava OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift Generics
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
Introduction Big Data and Hadoop
Introduction Big Data and HadoopIntroduction Big Data and Hadoop
Introduction Big Data and Hadoop
 
The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.2 book - Part 24 of 84The Ring programming language version 1.2 book - Part 24 of 84
The Ring programming language version 1.2 book - Part 24 of 84
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
Laporan Resmi Algoritma dan Struktur Data :
Laporan Resmi Algoritma dan Struktur Data : Laporan Resmi Algoritma dan Struktur Data :
Laporan Resmi Algoritma dan Struktur Data :
 
delegates
delegatesdelegates
delegates
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
 
WorkingWithSlick2.1.0
WorkingWithSlick2.1.0WorkingWithSlick2.1.0
WorkingWithSlick2.1.0
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)
"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)
"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)
 

Semelhante a How to Create Database component -Enterprise Application Using C# Lab

4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
Adil Jafri
 
C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-Collections
Mohammad Shaker
 

Semelhante a How to Create Database component -Enterprise Application Using C# Lab (20)

Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
C# p9
C# p9C# p9
C# p9
 
New text document
New text documentNew text document
New text document
 
Database c# connetion
Database c# connetionDatabase c# connetion
Database c# connetion
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP
 
37c
37c37c
37c
 
3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdf
 
interface with mysql.pptx
interface with mysql.pptxinterface with mysql.pptx
interface with mysql.pptx
 
The Ring programming language version 1.2 book - Part 26 of 84
The Ring programming language version 1.2 book - Part 26 of 84The Ring programming language version 1.2 book - Part 26 of 84
The Ring programming language version 1.2 book - Part 26 of 84
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-Collections
 
Sql server-function
Sql server-functionSql server-function
Sql server-function
 
Code
CodeCode
Code
 

Mais de priya Nithya

Mais de priya Nithya (19)

Android Architecture.pptx
Android Architecture.pptxAndroid Architecture.pptx
Android Architecture.pptx
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LABHTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
 
HTML SERVER CONTROL - ASP.NET WITH C#
HTML SERVER CONTROL  - ASP.NET WITH C#HTML SERVER CONTROL  - ASP.NET WITH C#
HTML SERVER CONTROL - ASP.NET WITH C#
 
Android LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio buttonAndroid LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio button
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
 
Web application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration fileWeb application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration file
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by step
 
Adaptation of tcp window
Adaptation of tcp windowAdaptation of tcp window
Adaptation of tcp window
 
Asp.net Overview
Asp.net OverviewAsp.net Overview
Asp.net Overview
 
Key mechanism of mobile ip
Key mechanism of mobile ip Key mechanism of mobile ip
Key mechanism of mobile ip
 
Mobile ip overview
Mobile ip overviewMobile ip overview
Mobile ip overview
 
Features of mobile ip
Features of mobile ipFeatures of mobile ip
Features of mobile ip
 
Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#
 
Creating simple component
Creating simple componentCreating simple component
Creating simple component
 
Internet (i mcom)
Internet (i mcom)Internet (i mcom)
Internet (i mcom)
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

How to Create Database component -Enterprise Application Using C# Lab

  • 1. Studb.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; namespace student { public class studb { public string getId(string sqlquery, SqlConnection connectionstring, ComboBox combox1) { DataSet ds = new DataSet(); SqlDataAdapter adap = new SqlDataAdapter(sqlquery, connectionstring); adap.Fill(ds, "student"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { combox1.Items.Add(ds.Tables[0].Rows[i][0].ToString()); } return null; } public string add(string id, string name, string dept, string phone, SqlConnection connectionstring) { string sqlquery = "insert into student(id,name,dept,phone) values ('" + id + "','" + name + "','" + dept + "','" + phone + "')"; SqlCommand cmd = new SqlCommand(sqlquery,connectionstring ); //connectionstring.Open(); try { cmd.ExecuteNonQuery(); MessageBox.Show("Inserted"); } catch (Exception e) { MessageBox.Show("not inserted"); } return null;
  • 2. } public string showgrid(string sqlquery, SqlConnection connectionstring, DataGridView grid1) { DataSet ds = new DataSet(); SqlDataAdapter adap = new SqlDataAdapter(sqlquery, connectionstring); adap.Fill(ds, "student"); grid1.DataSource = ds; grid1.DataMember = "student"; return null; } } } ************************ Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using student; using System.Data.SqlClient; namespace college { public partial class Form1 : Form { SqlConnection con = new SqlConnection(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { con.ConnectionString = @"Data Source=(LocalDB)v11.0;AttachDbFilename=E:c#studentstudentCollege.mdf;Integrated Security=True";
  • 3. con.Open(); string sqlquery = "select id from student"; studb st = new studb(); st.getId(sqlquery, con, comboBox1); } private void label1_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { string sqlquery = "Select * from student where id='"+comboBox1.Text +"'"; studb st = new studb(); st.showgrid(sqlquery, con, dataGridView1); } private void button1_Click(object sender, EventArgs e) { studb st = new studb(); st.add(textBox1.Text, textBox2.Text, textBox3.Text,textBox4.Text, con); } private void Exit_Click(object sender, EventArgs e) { this.Close(); } } }