.NET WinForms

Moderators: None (Apply to moderate this forum)
Number of threads: 117
Number of posts: 158

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

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?




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 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.
Operated by CommunityHeaven, a BootstrapLabs company.