Click here to Skip to main content
15,913,487 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questioncode for delete Pin
SwatiPathania21-May-06 22:50
SwatiPathania21-May-06 22:50 
GeneralRe: code for delete Pin
_AK_22-May-06 1:14
_AK_22-May-06 1:14 
AnswerRe: code for delete Pin
Mohammed Amine22-May-06 1:23
Mohammed Amine22-May-06 1:23 
GeneralRe: code for delete Pin
Colin Angus Mackay22-May-06 1:37
Colin Angus Mackay22-May-06 1:37 
GeneralRe: code for delete Pin
Mohammed Amine22-May-06 1:49
Mohammed Amine22-May-06 1:49 
GeneralRe: code for delete Pin
Colin Angus Mackay22-May-06 1:57
Colin Angus Mackay22-May-06 1:57 
GeneralRe: code for delete Pin
Mohammed Amine22-May-06 2:00
Mohammed Amine22-May-06 2:00 
AnswerRe: code for delete Pin
Colin Angus Mackay22-May-06 1:42
Colin Angus Mackay22-May-06 1:42 
SwatiPathania wrote:
Can anyone tell me the code (in vb.net) to delete one record from the database.


You don't mention what database. So, I'll assume SQL Server.

I've also assumed you have a String called connectionString which contains the connection string to your database. And, you have a variable called primaryKeyValue that matches the primaryKey of the row in the database that you want to delete.
Dim conn As SqlConnection = New SqlConnection(connectionString)
Dim cmd As SqlCommand = New SqlCommand
cmd.Connection = conn
cmd.CommandText = "DELETE FROM MyTable WHERE PrimaryKey = @primaryKey"
cmd.Parameters.Add("@primaryKey", primaryKeyValue)
cmd.ExecuteNonQuery()


Does this help?


DISCLAIMER: I'm not a VB.NET developer there may be some minor syntactic errors, but the logic is valid


"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)

My: Website | Blog
GeneralRe: code for delete Pin
Joshua Quick22-May-06 8:32
Joshua Quick22-May-06 8:32 
AnswerRe: code for delete Pin
Guffa22-May-06 10:24
Guffa22-May-06 10:24 
GeneralRe: code for delete Pin
Joshua Quick22-May-06 12:15
Joshua Quick22-May-06 12:15 
AnswerRe: code for delete Pin
ADY00724-May-06 22:50
ADY00724-May-06 22:50 
QuestionError: Property 'keycode' is non-nullable Pin
slyth21-May-06 22:29
slyth21-May-06 22:29 
QuestionDBConcurrencyException Pin
militiaware21-May-06 21:55
militiaware21-May-06 21:55 
AnswerRe: DBConcurrencyException Pin
Mekong River21-May-06 22:14
Mekong River21-May-06 22:14 
QuestionSending large files using Asynchronous Socket Problem?Plz Help :( Pin
shelal21-May-06 21:46
shelal21-May-06 21:46 
AnswerRe: Sending large files using Asynchronous Socket Problem?Plz Help :( Pin
Mekong River21-May-06 22:11
Mekong River21-May-06 22:11 
GeneralRe: Sending large files using Asynchronous Socket Problem?Plz Help :( Pin
shelal22-May-06 22:54
shelal22-May-06 22:54 
GeneralRe: Sending large files using Asynchronous Socket Problem?Plz Help :( Pin
Mekong River23-May-06 5:12
Mekong River23-May-06 5:12 
QuestionGet binary data from MS Access database into VB.Net Pin
Loiste21-May-06 21:22
Loiste21-May-06 21:22 
AnswerRe: Get binary data from MS Access database into VB.Net Pin
Mekong River21-May-06 22:19
Mekong River21-May-06 22:19 
QuestionProblem in getting a reference [modified] Pin
narayanagvs21-May-06 21:15
narayanagvs21-May-06 21:15 
QuestionRemote Login Pin
nitin_ion21-May-06 20:24
nitin_ion21-May-06 20:24 
AnswerRe: Remote Login Pin
Mekong River21-May-06 22:21
Mekong River21-May-06 22:21 
GeneralRe: Remote Login [modified] Pin
nitin_ion21-May-06 23:38
nitin_ion21-May-06 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.