How do I delete records using data reader?
The procedure for updating records using INSERT commands is very similar to the one we presented in the previous example (of SELECT) except that here the command does not return anything and thus the method to call on the SqlCommand object is called ExecuteNonQuery().C# Version
string connString = "server=FARAZ; database=programmersheaven;" + "uid=sa; pwd="; SqlConnection conn = new SqlConnection(connString); // DELETE Query string cmdString = "DELETE FROM Author " + "WHERE authorId = 3"; SqlCommand cmd = new SqlCommand(cmdString, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close();
VB.Net Version
Dim connString As String = "server=FARAZ; database=programmersheaven;" + _
"uid=sa; pwd="
Dim conn As New SqlConnection(connString)
' DELETE Query
Dim cmdString As String = "DELETE FROM Author " +
"WHERE authorId = 3"
Dim cmd As New SqlCommand(cmdString, conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Back
Sponsored links
Check For Updates
Easily add update features to your applications. A complete .Net updating solution.
Easily add update features to your applications. A complete .Net updating solution.
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Online Crash Analysis
Automatically capture customer crash data, no debugger required. Support for .NET, C++, OS X, Java.
Automatically capture customer crash data, no debugger required. Support for .NET, C++, OS X, Java.
.Net Localization Tool Sisulizer
Localize your .Net apps: ResX and assemblies. Database, XML & HTML Help localization. Try Sisulizer!
Localize your .Net apps: ResX and assemblies. Database, XML & HTML Help localization. Try Sisulizer!
