Know a good article or link that we're missing? Submit it!

.NET WinForms

Moderators: None (Apply to moderate this forum)
Number of threads: 106
Number of posts: 145

This Forum Only
Post New Thread

Report
delete command using DataAdapter in c# Posted by Nishanth_mahe on 17 Nov 2009 at 2:36 AM
Hi All,
I am trying to insert/update/delete a field from my sql server table using dataadapter in c# windows application.

Here insert and update are happening,but 'delete' is not working

I will show my delete part :

public int UpdateAllUserDetails(DataSet dsUsers)
{
private SqlConnection connection;
private SqlCommand command;
private SqlDataAdapter dataAdapter;

connection = new SqlConnection(ConfigurationManager.AppSettings.Get("conString"));
connection.Open();
dataAdapter = new SqlDataAdapter(command);

dataAdapter.DeleteCommand = new SqlCommand("DELETE FROM UserDetails WHERE vUserName=@vUserName", connection);
dataAdapter.DeleteCommand.Parameters.Add("@vUserName", SqlDbType.VarChar, 50, "vUserName");

int ret = dataAdapter.Update(dsUsers);
return ret;

}

can somebody say what is missing here?




 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A BootstrapLabs project.