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

+454 Recommend this on Google Tutorials Forum Career Development Resources

Follow us on Twitter: https://twitter.com/dotnetspider


Reviews Jobs Interview Communities

Silverlight Games | Bookmarks | New Members FAQ | Mentor | C ode C onverter | IT C ompanies | Peer Appraisal | Members | Revenue Sharing

DotNetSpider
di Facebook Suka 4,058 orang menyukai DotNetSpider.

R s u c s . E p o r m i g . E F a e o k eore NT rgamn NT rmwr

Select, Insert, Update and delete Operation in VB.Net and MySQL


Posted Date: 06-Aug-2011 Category: .NET Framework Rating: Points: 10 (Rs 3) Author: Suresh Sellathambi Member Level: Gold

S amnang

P anguluri

Su

G aw eshanay a

I am Creating Windows application using VB.Net. In this Article you will learn about Select, Insert, Update and delete Operation in VB.Net and MySQL. Here I am displaying Records in Datagridview from MySQL Database.
Indralugin sosial P N ath F acebook

Talk to Webmaster Tony John

Facebook Google+ Twitter LinkedIn

Online Members
Asheej T K Janson Sreedevi U.V Ranjith Saranya
More ...

Library RFID Systems


Self Serve C heck Out - Self Returns Book Sorters, Stock Take, Payments
www.fe te chgroup.com .au

SAP Sybase ASE


High End Performance w/o High C osts Use Sybase ASE w SAP C RM software!
www.SAP.com /Indone sia

Simple Injector
Open source dependency injection container for .NET.
sim ple inje ctor.code ple x .com

SA Criminal Clearance
C riminal C learance within 72 hours Remove of old SA C riminal Records
www.ne ve te cpolice cle arance .co.za

Introduction Datagridview from MySQL Database.

I am Creating one VB.NET Windows application.In this Application I am going to explain about Select, Insert, Update and delete Operation in VB.Net and MySQL

I am Creating windows application in vb.net named Myproject. In this application I am using Three Textbox, Datagridview, Four Button controls and Four Labels I am using Following Textbox Controls and its name : txtUserid.Text: It is used to get the user id from users. txtUserName.Text : It is used to get the user name from users. txtAge.Text : It is used to get the age of the users from users. I am using Following Button Controls and its name :

www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx

DisplayRecords : if you click the DisplayRecords button, the user details will display in DataGridview.

1/6

DisplayRecords : if you click the DisplayRecords button, the user details will display in DataGridview. AddRecords : if you click the AddRecords button, the user details will store in data base table. UpdateRecords : if you click the UpdateRecords button,the user details will update from data base table. DeleteRecords : if you click the DeleteRecords button, the user details will delete from data base table. DataGridview1 is used to display user details. If you want to Connect VB.Net with MySQL Data base, You Should use MySql.Data.MySqlClient Namespace. It Contains MySQL Connection class and Methods. MySqlConnection :it is used connect VB.NEt with MySQL Data Base. MySqlCommand : It is used to excute the command MySqlDataAdapter :it is acting as bridge between MySQL and VB.Net.

IprsMSlDt.yqCin mot yq.aaMSllet

MySqlConnection Class is used to connect to MySQL database.

DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI=otP i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe Dro;

Diaplay Records in DataGridview from MySQL Database.Display Records in VB.Net from MySQL Database

PiaeSbDslyeod_lc(ya sne A Sse.bet BVleA Sse.vnAg)Hnls rvt u ipaRcrsCikBVl edr s ytmOjc, ya s ytmEetrs ade DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe DmslA MSlomn =NwMSlomn(SLC *FO uerg,cn i q s yqCmad e yqCmad"EET RM sre" o) Dmd A DtSt=NwDtSt) i s s aae e aae( DmDtAatr A MSlaadpe =NwMSlaadpe( i aadpe1 s yqDtAatr e yqDtAatr) cnOe( o.pn) DtAatr.eetomn =sl aadpe1SlcCmad q DtAatr.ild,"rdc" aadpe1Fl(s Pout) DtGiVe1DtSuc =d aardiw.aaore s DtGiVe1DtMme ="rdc" aardiw.aaebr Pout cnCoe) o.ls( EdSb n u

Insert Records in MySql Database.

PiaeSbAdeod_lc(ya sne A Sse.bet BVleA Sse.vnAg)HnlsBt rvt u dRcrsCikBVl edr s ytmOjc, ya s ytmEetrs ade u DmQeyA Srn i ur s tig 'ur ="NETIT uerg Qey ISR NO sre" DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe 'i slA MSlomn =NwMSlomn(ur,cn Dm q s yqCmad e yqCmadQey o) Qey="NETIT uergiUeRgUeNm,AeVLE( ur ISR NO sre(dsre,srae g)AUS" Qey=Qey+ttsreI.et+"' +ttsraeTx +", +ttg.et+"" ur ur xUeRgdTx ," xUeNm.et '" xAeTx ) cnOe( o.pn) DmcdA MSlomn =NwMSlomn(ur,cn i m s yqCmad e yqCmadQey o) DmiA Itgr=cdEeueoQey) i s nee m.xctNnur( I ( >0 Te f i ) hn lls.et="eodi Scesul Isre" bMgTx Rcr s ucsfly netd Es le
www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx 2/6

Es le lls.et="eodi ntIsre" bMgTx Rcr s o netd EdI n f cnCoe) o.ls( EdSb n u

Update Records from MySQL Database.

PiaeSbUdtRcrsCikBVlsne A Sse.bet BVleA Sse.vnAg)Hnls rvt u paeeod_lc(ya edr s ytmOjc, ya s ytmEetrs ade DmQeyA Srn i ur s tig

DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe cnOe( o.pn) Qey="PAEuergSTUeNm ="+ttsraeTx +", ur UDT sre E srae ' xUeNm.et '" Qey=Qey+"g ="+ttg.et ur ur Ae xAeTx Qey=Qey+"WEEiUeRg="+ttsreI.et ur ur HR dsre xUeRgdTx DmcdA MSlomn =NwMSlomn(ur,cn i m s yqCmad e yqCmadQey o) Mgo(ur) sBxQey DmiA Itgr=cdEeueoQey) i s nee m.xctNnur( I ( >0 Te f i ) hn lls.et="eodi Scesul Udtd bMgTx Rcr s ucsfly pae" Es le lls.et="eodi ntUdtd bMgTx Rcr s o pae" EdI n f cnCoe) o.ls( EdSb n u

Delete Records from MySQL Database

PiaeSbDltRcrsCikBVlsne A Sse.bet BVleA Sse.vnAg)Hnls rvt u eeeeod_lc(ya edr s ytmOjc, ya s ytmEetrs ade DmQeyA Srn i ur s tig

DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe cnOe( o.pn) Qey="eeeFO uergWEEiUeRg = +ttsreI.et ur Dlt RM sre HR dsre " xUeRgdTx DmcdA MSlomn =NwMSlomn(ur,cn i m s yqCmad e yqCmadQey o) Mgo(ur) sBxQey DmiA Itgr=cdEeueoQey) i s nee m.xctNnur( I ( >0 Te f i ) hn lls.et="eodi Scesul Dltd bMgTx Rcr s ucsfly eee" Es le lls.et="eodi ntDltd bMgTx Rcr s o eee" EdI n f cnCoe) o.ls( EdSb n u

MySQL Database Here I am creating table in MySQL Data base with Following Fields. The Table Name is userreg. idUserReg : int UserName : Varchar Age : int OutPut

www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx

3/6

Finally We Create Windows Application in VB.Net with MySQL Database. Here Insert, update, Delete and display Records in grid view.Creating Windows applica VB.Net if you want to know about How to Upload Excel file in ASP.Net Applications. Please Refer Following Link. Upload Excel file in ASP.Net Applications Thanks for spending your valuable time.if you have any doubts or any Suggestion , Let Me know. I am Happy to update here. Hope you will enjoy this article and provide your valuable suggestion and feedback. Thanks Happy Coding.....

Did you like this resource? Share it with your friends and show your love!
0
Share Tw eet 0
Share

10

Suka

10 orang menyukai ini.

Responses to "Select, Insert, Update and delete Operation in VB.Net and MySQL"
Guest Author: Syawal1 24 Apr 2012

Sir may i ask where do "product" come from and i have error it said Fill : SelectCommand.Connection property has not been initialized. which is at dataAdapter1.Fill(ds,"product")

Author: Suresh Sellathambi Hi Syawal,

25 Apr 2012

Member Level: Gold Points : 2

Please check the Data base connection whether you are giving correct or not.

DmcnA MSloncin=NwMSloncin"aaSuc=oahs;aaaets;srI=otP i o s yqCneto e yqCneto(Dt orelclotDtbs=etUe Dro; D m Clouds M much more:d = N i q yqCma e yqCmad"EET RM sre" o) Hackathon, Commerce,s l A and S l o m n Sprint w M S l o m n ( S L C * F O u e r g , c n Open Solutions Conference. Details here.
www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx 4/6

you can the using following code dataAdapter1.Fill(ds) instead dataAdapter1.Fill(ds,"product") Thanks and Regards S.Suresh

Guest Author: shiko

24 Jul 2012

Errore 2 L'espressione un valore, quindi non pu essere la destinazione di un'assegnazione.

Query = "INSERT INTO clienti(nome)VALUES(" Query = Query() + TextBox1.Text + ")"

Author: vijay

31 Jul 2012

Member Level: Bronze

Points : 1

I want to do something tricky. I hope you could help me. I have a database with self given id's. So, if I delete a record from the middle , for example I have id's like 1,2,3,4,5... and if I delete a record with id 3, records becomes 3 and 5 becomes 4. Is it possible in vb.net ?

Author: grace Hi Syawal,

11 Aug 2012

Member Level: Bronze

Points : 1

hello im a new programmer..and im working with vb.net connected to mysql ..and with regards with that..i used your code in insert data to mysql database but that i have to use mysql version of EXECUTENONQUERY please help me sir....

Feedbacks

Subscribe to Feedbacks

Un Subscribe

Post Comment:

Notify me by email when others post comments to this article. Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic. No HTML formatting and links to other web sites are allowed. This is a strictly moderated site. Absolutely no spam allowed. Name: Email: Sign In to fill automatically. (Will not be published, but required to validate comment)

Type the numbers and letters shown on the left.

Submit Response

Next Resource: How to define Global Variables in C#.Net Previous Resource: New Features of Windows Workflow Foundation 4.0 Return to Resources Post New Resource

More Resources How to define Global Variables in C#.Net What is cloning and how we inpmement it in asp.net

www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx

5/6

Sorting user defined collection in c# using IComparable interfac Category: .NET Framework Parallel Programming in .NET 4.0 - Part 2 Parallel Programming in .NET 4.0 - Part 1

Post resources and earn money!

Comparison of MVC implementation between J2EE Struts 2 & AS

Popular Tags

Tag posting guidelines

Search Tags

Select . Insert . Update and delete Operation in VB.Net and MySQL . MySQL Database Connection in VB.Net . Display Records in VB.Net fro

About Us

Contact Us

Copyright

Privacy Policy

Terms Of Use

Revenue Sharing sites

Advertise

Talk to

Copyright SpiderWorks Technologies Pvt Ltd., Kochi, India 2005 - 2012 All Rights Reserved.
.NET and othe r trade m ark s m e ntione d in this site be long to Microsoft and othe r re spe ctive trade m ark owne rs. Article s, tutorials and all othe r conte nt offe re d he re is for e ducational purpose only. W e are not associate d with Microsoft or its partne rs.

www.dotnetspider.com/resources/43175-Select-Insert-Update-delete-Operation.aspx

6/6

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