SlideShare a Scribd company logo
1 of 2
Download to read offline
in order to save data from access database and search from it in c# windows application form. i
created two buttons Save and Search . what codes should i write behind each of them to make
them work property.
note: it OLEDb connection
Solution
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;
SqlConnection conn;
SqlCommand comm;
SqlDataReader dreader;
private void btnsave_Click(object sender, EventArgs e)
{
conn = new SqlConnection(connstring);
conn.Open();
comm = new SqlCommand("insert into student_detail values(" + txtrn.Text + ",'" +
txtname.Text + "'," + txtage.Text + ",'" + txtcourse.Text + "')", conn);
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Saved...");
}
catch (Exception)
{
MessageBox.Show("Not Saved");
}
finally
{
conn.Close();
}
}
private void btnsearch_Click(object sender, EventArgs e)
{
conn = new SqlConnection(connstring);
conn.Open();
comm = new SqlCommand("select * from student_detail where roll_no = " + txtrn.Text
+ " ", conn);
try
{
dreader = comm.ExecuteReader();
if (dreader.Read())
{
txtname.Text = dreader[1].ToString();
txtage.Text = dreader[2].ToString();
txtcourse.Text = dreader[3].ToString();
}
else
{
MessageBox.Show(" No Record");
}
dreader.Close();
}
catch (Exception)
{
MessageBox.Show(" No Record");
}
finally
{
conn.Close();
}
}

More Related Content

Similar to in order to save data from access database and search from it in c# .pdf

3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdfManalAg
 
1- Create a Visual Calculator by using winform application in Microsof.docx
1- Create a Visual Calculator by using winform application in Microsof.docx1- Create a Visual Calculator by using winform application in Microsof.docx
1- Create a Visual Calculator by using winform application in Microsof.docxjbarbara1
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPAli Shah
 
Open microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutletOpen microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutletMitchinson
 
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185Mahmoud Samir Fayed
 
Client-server architecture (clientserver) is a network architecture .pdf
Client-server architecture (clientserver) is a network architecture .pdfClient-server architecture (clientserver) is a network architecture .pdf
Client-server architecture (clientserver) is a network architecture .pdffabmallkochi
 
SCons an Introduction
SCons an IntroductionSCons an Introduction
SCons an Introductionslantsixgames
 
Scaling Application in Node.js.pdf
Scaling Application in Node.js.pdfScaling Application in Node.js.pdf
Scaling Application in Node.js.pdfSudhanshiBakre1
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180Mahmoud Samir Fayed
 
Vb database connections
Vb database connectionsVb database connections
Vb database connectionsTharsikan
 

Similar to in order to save data from access database and search from it in c# .pdf (20)

3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdf
 
1- Create a Visual Calculator by using winform application in Microsof.docx
1- Create a Visual Calculator by using winform application in Microsof.docx1- Create a Visual Calculator by using winform application in Microsof.docx
1- Create a Visual Calculator by using winform application in Microsof.docx
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docx
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
 
Csharp
CsharpCsharp
Csharp
 
Open microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutletOpen microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutlet
 
Hems
HemsHems
Hems
 
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.4 book - Part 71 of 185
 
Client-server architecture (clientserver) is a network architecture .pdf
Client-server architecture (clientserver) is a network architecture .pdfClient-server architecture (clientserver) is a network architecture .pdf
Client-server architecture (clientserver) is a network architecture .pdf
 
SCons an Introduction
SCons an IntroductionSCons an Introduction
SCons an Introduction
 
Scaling Application in Node.js.pdf
Scaling Application in Node.js.pdfScaling Application in Node.js.pdf
Scaling Application in Node.js.pdf
 
Qtp test
Qtp testQtp test
Qtp test
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
 
Ditec esoft C# project
Ditec esoft C# projectDitec esoft C# project
Ditec esoft C# project
 
Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
 
C# p3
C# p3C# p3
C# p3
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 

More from kalerottnerheissst52

Explain why membranes are semifluid and describe how membrane compos.pdf
Explain why membranes are semifluid and describe how membrane compos.pdfExplain why membranes are semifluid and describe how membrane compos.pdf
Explain why membranes are semifluid and describe how membrane compos.pdfkalerottnerheissst52
 
At the movies, Lucinda bought food for herself and her friend Rae, i.pdf
At the movies, Lucinda bought food for herself and her friend Rae, i.pdfAt the movies, Lucinda bought food for herself and her friend Rae, i.pdf
At the movies, Lucinda bought food for herself and her friend Rae, i.pdfkalerottnerheissst52
 
Describe the characteristic symptoms of mood disorders (major depres.pdf
Describe the characteristic symptoms of mood disorders (major depres.pdfDescribe the characteristic symptoms of mood disorders (major depres.pdf
Describe the characteristic symptoms of mood disorders (major depres.pdfkalerottnerheissst52
 
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdf
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdfA slinky can demonstrate both a transverse and longitudinal wave. Ho.pdf
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdfkalerottnerheissst52
 
8) Network layer connection service is between A. two processes B. t.pdf
8) Network layer connection service is between A. two processes B. t.pdf8) Network layer connection service is between A. two processes B. t.pdf
8) Network layer connection service is between A. two processes B. t.pdfkalerottnerheissst52
 
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdf
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdfConsider the TCP multiple acknowledgement scheme. A base station (BS.pdf
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdfkalerottnerheissst52
 
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdfkalerottnerheissst52
 
Assume you found a new worm species while working at Friday Harbor M.pdf
Assume you found a new worm species while working at Friday Harbor M.pdfAssume you found a new worm species while working at Friday Harbor M.pdf
Assume you found a new worm species while working at Friday Harbor M.pdfkalerottnerheissst52
 
You are responsible for convening a major event in which senior offi.pdf
You are responsible for convening a major event in which senior offi.pdfYou are responsible for convening a major event in which senior offi.pdf
You are responsible for convening a major event in which senior offi.pdfkalerottnerheissst52
 
Write an expression that dynamically allocates sufficient memory to .pdf
Write an expression that dynamically allocates sufficient memory to .pdfWrite an expression that dynamically allocates sufficient memory to .pdf
Write an expression that dynamically allocates sufficient memory to .pdfkalerottnerheissst52
 
Which of the following organisms are most likely to have the lowest C.pdf
Which of the following organisms are most likely to have the lowest C.pdfWhich of the following organisms are most likely to have the lowest C.pdf
Which of the following organisms are most likely to have the lowest C.pdfkalerottnerheissst52
 
An individual who intents the gene for blood type A from one parent a.pdf
An individual who intents the gene for blood type A from one parent a.pdfAn individual who intents the gene for blood type A from one parent a.pdf
An individual who intents the gene for blood type A from one parent a.pdfkalerottnerheissst52
 
What refers to the transfer of emergy rom the more energetic particle.pdf
What refers to the transfer of emergy rom the more energetic particle.pdfWhat refers to the transfer of emergy rom the more energetic particle.pdf
What refers to the transfer of emergy rom the more energetic particle.pdfkalerottnerheissst52
 
What happens to a B-mode image without post processing filtersWha.pdf
What happens to a B-mode image without post processing filtersWha.pdfWhat happens to a B-mode image without post processing filtersWha.pdf
What happens to a B-mode image without post processing filtersWha.pdfkalerottnerheissst52
 
What characteristic do corals possess that CLASSIFIES them as animal.pdf
What characteristic do corals possess that CLASSIFIES them as animal.pdfWhat characteristic do corals possess that CLASSIFIES them as animal.pdf
What characteristic do corals possess that CLASSIFIES them as animal.pdfkalerottnerheissst52
 
Material Science question 17 Leaded glass (sometimes called crystal).pdf
Material Science question 17 Leaded glass (sometimes called crystal).pdfMaterial Science question 17 Leaded glass (sometimes called crystal).pdf
Material Science question 17 Leaded glass (sometimes called crystal).pdfkalerottnerheissst52
 
True or False. Sequential access storage devices allow data to be ac.pdf
True or False. Sequential access storage devices allow data to be ac.pdfTrue or False. Sequential access storage devices allow data to be ac.pdf
True or False. Sequential access storage devices allow data to be ac.pdfkalerottnerheissst52
 
Translate the following C code to MIPS. Assume that the variables f, .pdf
Translate the following C code to MIPS. Assume that the variables f, .pdfTranslate the following C code to MIPS. Assume that the variables f, .pdf
Translate the following C code to MIPS. Assume that the variables f, .pdfkalerottnerheissst52
 
The right answer!! Which of the following correctly list the simple .pdf
The right answer!! Which of the following correctly list the simple .pdfThe right answer!! Which of the following correctly list the simple .pdf
The right answer!! Which of the following correctly list the simple .pdfkalerottnerheissst52
 
The phylogeny in this figure shows the evolution of visual opsins in.pdf
The phylogeny in this figure shows the evolution of visual opsins in.pdfThe phylogeny in this figure shows the evolution of visual opsins in.pdf
The phylogeny in this figure shows the evolution of visual opsins in.pdfkalerottnerheissst52
 

More from kalerottnerheissst52 (20)

Explain why membranes are semifluid and describe how membrane compos.pdf
Explain why membranes are semifluid and describe how membrane compos.pdfExplain why membranes are semifluid and describe how membrane compos.pdf
Explain why membranes are semifluid and describe how membrane compos.pdf
 
At the movies, Lucinda bought food for herself and her friend Rae, i.pdf
At the movies, Lucinda bought food for herself and her friend Rae, i.pdfAt the movies, Lucinda bought food for herself and her friend Rae, i.pdf
At the movies, Lucinda bought food for herself and her friend Rae, i.pdf
 
Describe the characteristic symptoms of mood disorders (major depres.pdf
Describe the characteristic symptoms of mood disorders (major depres.pdfDescribe the characteristic symptoms of mood disorders (major depres.pdf
Describe the characteristic symptoms of mood disorders (major depres.pdf
 
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdf
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdfA slinky can demonstrate both a transverse and longitudinal wave. Ho.pdf
A slinky can demonstrate both a transverse and longitudinal wave. Ho.pdf
 
8) Network layer connection service is between A. two processes B. t.pdf
8) Network layer connection service is between A. two processes B. t.pdf8) Network layer connection service is between A. two processes B. t.pdf
8) Network layer connection service is between A. two processes B. t.pdf
 
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdf
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdfConsider the TCP multiple acknowledgement scheme. A base station (BS.pdf
Consider the TCP multiple acknowledgement scheme. A base station (BS.pdf
 
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf
3. A surface water has pH 7.2. What type of alkalinity should we expe.pdf
 
Assume you found a new worm species while working at Friday Harbor M.pdf
Assume you found a new worm species while working at Friday Harbor M.pdfAssume you found a new worm species while working at Friday Harbor M.pdf
Assume you found a new worm species while working at Friday Harbor M.pdf
 
You are responsible for convening a major event in which senior offi.pdf
You are responsible for convening a major event in which senior offi.pdfYou are responsible for convening a major event in which senior offi.pdf
You are responsible for convening a major event in which senior offi.pdf
 
Write an expression that dynamically allocates sufficient memory to .pdf
Write an expression that dynamically allocates sufficient memory to .pdfWrite an expression that dynamically allocates sufficient memory to .pdf
Write an expression that dynamically allocates sufficient memory to .pdf
 
Which of the following organisms are most likely to have the lowest C.pdf
Which of the following organisms are most likely to have the lowest C.pdfWhich of the following organisms are most likely to have the lowest C.pdf
Which of the following organisms are most likely to have the lowest C.pdf
 
An individual who intents the gene for blood type A from one parent a.pdf
An individual who intents the gene for blood type A from one parent a.pdfAn individual who intents the gene for blood type A from one parent a.pdf
An individual who intents the gene for blood type A from one parent a.pdf
 
What refers to the transfer of emergy rom the more energetic particle.pdf
What refers to the transfer of emergy rom the more energetic particle.pdfWhat refers to the transfer of emergy rom the more energetic particle.pdf
What refers to the transfer of emergy rom the more energetic particle.pdf
 
What happens to a B-mode image without post processing filtersWha.pdf
What happens to a B-mode image without post processing filtersWha.pdfWhat happens to a B-mode image without post processing filtersWha.pdf
What happens to a B-mode image without post processing filtersWha.pdf
 
What characteristic do corals possess that CLASSIFIES them as animal.pdf
What characteristic do corals possess that CLASSIFIES them as animal.pdfWhat characteristic do corals possess that CLASSIFIES them as animal.pdf
What characteristic do corals possess that CLASSIFIES them as animal.pdf
 
Material Science question 17 Leaded glass (sometimes called crystal).pdf
Material Science question 17 Leaded glass (sometimes called crystal).pdfMaterial Science question 17 Leaded glass (sometimes called crystal).pdf
Material Science question 17 Leaded glass (sometimes called crystal).pdf
 
True or False. Sequential access storage devices allow data to be ac.pdf
True or False. Sequential access storage devices allow data to be ac.pdfTrue or False. Sequential access storage devices allow data to be ac.pdf
True or False. Sequential access storage devices allow data to be ac.pdf
 
Translate the following C code to MIPS. Assume that the variables f, .pdf
Translate the following C code to MIPS. Assume that the variables f, .pdfTranslate the following C code to MIPS. Assume that the variables f, .pdf
Translate the following C code to MIPS. Assume that the variables f, .pdf
 
The right answer!! Which of the following correctly list the simple .pdf
The right answer!! Which of the following correctly list the simple .pdfThe right answer!! Which of the following correctly list the simple .pdf
The right answer!! Which of the following correctly list the simple .pdf
 
The phylogeny in this figure shows the evolution of visual opsins in.pdf
The phylogeny in this figure shows the evolution of visual opsins in.pdfThe phylogeny in this figure shows the evolution of visual opsins in.pdf
The phylogeny in this figure shows the evolution of visual opsins in.pdf
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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).pptxVishalSingh1417
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
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 ClassesCeline George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
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.pptxDenish Jangid
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
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 . pdfQucHHunhnh
 
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 SDThiyagu K
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
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
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.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
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
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
 

in order to save data from access database and search from it in c# .pdf

  • 1. in order to save data from access database and search from it in c# windows application form. i created two buttons Save and Search . what codes should i write behind each of them to make them work property. note: it OLEDb connection Solution 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; SqlConnection conn; SqlCommand comm; SqlDataReader dreader; private void btnsave_Click(object sender, EventArgs e) { conn = new SqlConnection(connstring); conn.Open(); comm = new SqlCommand("insert into student_detail values(" + txtrn.Text + ",'" + txtname.Text + "'," + txtage.Text + ",'" + txtcourse.Text + "')", conn); try { comm.ExecuteNonQuery(); MessageBox.Show("Saved..."); } catch (Exception) { MessageBox.Show("Not Saved"); }
  • 2. finally { conn.Close(); } } private void btnsearch_Click(object sender, EventArgs e) { conn = new SqlConnection(connstring); conn.Open(); comm = new SqlCommand("select * from student_detail where roll_no = " + txtrn.Text + " ", conn); try { dreader = comm.ExecuteReader(); if (dreader.Read()) { txtname.Text = dreader[1].ToString(); txtage.Text = dreader[2].ToString(); txtcourse.Text = dreader[3].ToString(); } else { MessageBox.Show(" No Record"); } dreader.Close(); } catch (Exception) { MessageBox.Show(" No Record"); } finally { conn.Close(); } }