Click here to Skip to main content
15,915,172 members
Home / Discussions / C#
   

C#

 
GeneralRe: Custom Control Problem Pin
Guinness4Strength22-Feb-04 5:21
Guinness4Strength22-Feb-04 5:21 
GeneralSetting visibility of parent form from child. Pin
POnfri21-Feb-04 12:58
POnfri21-Feb-04 12:58 
GeneralRe: Setting visibility of parent form from child. Pin
POnfri21-Feb-04 15:09
POnfri21-Feb-04 15:09 
GeneralRe: Setting visibility of parent form from child. Pin
partyganger22-Feb-04 4:22
partyganger22-Feb-04 4:22 
Generaloverride vrs Event capturing Pin
Anonymous21-Feb-04 10:54
Anonymous21-Feb-04 10:54 
GeneralRe: override vrs Event capturing Pin
Charlie Williams21-Feb-04 11:18
Charlie Williams21-Feb-04 11:18 
GeneralRe: override vrs Event capturing Pin
Heath Stewart21-Feb-04 11:57
protectorHeath Stewart21-Feb-04 11:57 
QuestionHow to Delete a row using DeleteCommand of DataAdapter? Pin
gr8tushar21-Feb-04 9:10
gr8tushar21-Feb-04 9:10 
Hii
i m trying to delete a row using DeleteCommand of DataAdapter, but i can't.
i m using this code..


using System;
using System.Data;
using System.Data.SqlClient;

class ModifyDataTable
{
static void Main()
{
string constr = @"server=(local)\NetSDK;Integrated Security=true;"+
"database=address";
SqlConnection Conn = new SqlConnection(constr);
try
{
string SQL = "SELECT * from Hello";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(SQL,Conn);

DataSet ds = new DataSet();
da.Fill(ds,"Hello");

DataTable dt = ds.Tables ["Hello"];
("Select * From Hello",Conn);
foreach( DataRow r in dt.Rows)
{
Console.WriteLine("{0} {1}",r["Name"].ToString ().PadRight (15),
r["Phone"].ToString ().PadLeft(25));
}
Console.WriteLine("\n" + dt.Rows .Count.ToString ());
da.DeleteCommand = new SqlCommand ("DELETE FROM Hello WHERE (Name='Amit')" ,Conn);
da.Update (ds,"Hello");
Console.WriteLine ("\n" + dt.Rows.Count.ToString ());
foreach( DataRow r in dt.Rows)
{
Console.WriteLine("{0} {1}",r["Name"].ToString ().PadRight (15),
r["Phone"].ToString ().PadLeft(25));
}
}
catch (Exception e)
{
Console.WriteLine ("Error Occured : " +e.Message );
Conn.Close ();
}
finally
{
Conn.Close();
Console.ReadLine ();
}
}
}

This isn't deleting anything neither in the dataset nor in the database




AnswerRe: How to Delete a row using DeleteCommand of DataAdapter? Pin
Charlie Williams21-Feb-04 11:01
Charlie Williams21-Feb-04 11:01 
GeneralDirectx SampleGrabberNET help Pin
russ.trow21-Feb-04 9:08
russ.trow21-Feb-04 9:08 
GeneralApplication Icons Pin
dbetting21-Feb-04 8:53
dbetting21-Feb-04 8:53 
Generalv small job for c# developer £50 Pin
notsosharp21-Feb-04 8:11
notsosharp21-Feb-04 8:11 
GeneralRe: v small job for c# developer £50 Pin
John Kuhn21-Feb-04 8:19
John Kuhn21-Feb-04 8:19 
GeneralRe: v small job for c# developer £50 Pin
Mazdak21-Feb-04 10:37
Mazdak21-Feb-04 10:37 
GeneralRe: v small job for c# developer £50 Pin
Kannan Kalyanaraman21-Feb-04 22:04
Kannan Kalyanaraman21-Feb-04 22:04 
GeneralRe: v small job for c# developer £50 Pin
partyganger22-Feb-04 4:16
partyganger22-Feb-04 4:16 
Generalcode editor Pin
EgySoft21-Feb-04 7:47
sussEgySoft21-Feb-04 7:47 
GeneralRe: code editor Pin
Kannan Kalyanaraman21-Feb-04 21:59
Kannan Kalyanaraman21-Feb-04 21:59 
Generalcode editor Pin
Anonymous21-Feb-04 7:43
Anonymous21-Feb-04 7:43 
GeneralLaunch console app with no window under win9x Pin
LokiSD21-Feb-04 6:13
LokiSD21-Feb-04 6:13 
GeneralRe: Launch console app with no window under win9x Pin
Heath Stewart21-Feb-04 11:45
protectorHeath Stewart21-Feb-04 11:45 
GeneralRe: Launch console app with no window under win9x Pin
LokiSD22-Feb-04 0:23
LokiSD22-Feb-04 0:23 
GeneralRe: Launch console app with no window under win9x Pin
Jörgen Sigvardsson22-Feb-04 7:31
Jörgen Sigvardsson22-Feb-04 7:31 
GeneralRe: Launch console app with no window under win9x Pin
LokiSD22-Feb-04 8:18
LokiSD22-Feb-04 8:18 
GeneralOwn FileDialog Pin
CH21-Feb-04 3:27
CH21-Feb-04 3:27 

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.