Control Panel
Forum
Hosting Help
ASP.NET 3.5 & SQL 2008 Web Hosting
Resources
Login
Members
Shared Hosting
|
New Features
|
Advertise
|
Tutorials
|
Silverlight Tutorials
|
Product Reviews in India
|
Free aptitude test questions
|
TATA Nano Car reviews
Total
members
:
90131
Average new registrations per day (in last 7 days):
94
New Registration:
Open
Register Now
Home
»
Questions & Answers
»
how 2 delete a record from my database
how 2 delete a record from my database
4/22/2008
Author:
shahin khan
i do my coding in Vb.net
i have a table call dinner details in Sql 2000
colunms are 1) rid 2) Date 3) canteenid 4) Itemname
i have listbox in which i shw the itemname frm my database
my listbox is have itemname as folloe
Roti
Rice
Puri
Dal
frm the lstbox i delete the item Puri then i shld be delete frm database as well as lsitbox
i have a delete btn
plz tell me how can i get rid so tht i can delete the record frm database
Protected Sub btndelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndelete.Click
con = GetConnection()
If con.State = ConnectionState.Closed Then con.Open()
If lbld.Items.Count >= 0 Then
Dim str As String = "DELETE FROM Dinnerdetail where rid ='" & rid & "'"
Dim cmd As New SqlCommand(Str, con)
cmd.ExecuteNonQuery()
plz tell me the correct code i neeed it is urgent
Answers .............
Author:
Mandalika V Harish
Posted Date: 6/12/2008
well, first of all i program in c#, so i ll provide a code snippet in that, hope it helps you.
see first, whats rid.
well lets assume, the "ListBox1.SelectedItem" property which you need to read at the runtime.
//--------------------------------------------------------
String cs="your connection string";
Sqlconnection cn=new Sqlconnection(cs);
String item=ListBox1.SelectedItem;
String str="delete from Dinnerdetail where rid='"+item+"'";
Sqlcommand cmd=new Sqlcommand(str,cn);
try{ cn.open; cmd.ExecuteNonQuery(); cn.close(); }
catch{}
//--------------------------------------------------------
well hope it helps you.
You must
login
to post answer for this question.
Partners
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies.
All Rights Reserved.