|
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
|
|
|
|
|
You should use a DataAdapter when you want your updates and deletes to be managed for you depending on the state of the DataSet .
In your case, you are not altering the <cpde>DataSet, so your delete command is never used.
If you just want to execute a specific delete command:
string sql = "DELETE FROM Hello WHERE (Name='Amit');
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
Charlie
if(!curlies){ return; }
|
|
|
|
|
Im trying to work out how i would go about altering the C# DirectX example "SampleGrabberNET" so i could perform captures from a video file (avi,mpeg,etc) rather than a capture device.
Extremely confused, i can see how the video player example works but not how i intergrate the 2 examples.
Cheers.
|
|
|
|
|
I tried to modify a couple of the icons supplied with .Net using the icon editor I've been using for years. The strange thing is that after I've opened the icon and saved it (even without changes), I can not use the icon as intended.
If an existing icon to a button, it fits nicely into the button as it should. I open the icon and find it is a standard 32x32 icon and save it as a new icon (with or without changes). If I then use the new icon on the same button, the icon is way too big to fit.
Can anybody explain what is different about this new icon that it no longer fits? Is there a recommended tool that I should now be using to create my icons?
Thanks.
db
|
|
|
|
|
hi, anyone out there help me with a c# project, trying to write code involving methods and if else statments - beginners stuff
i'm confused can pay for your time
|
|
|
|
|
1) Rather than paying someone for their time, why not get a book?
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
|
You'd get a better response if you post a question here with the problem you encountered on your code.
|
|
|
|
|
Exactly, if it';s beginenr stuff, just post the code and probably somebody'll pick it up...
|
|
|
|
|
hi all,
this days ,i make Assemby ide , but i hae a probem with the resered words to be highlighted ,i want an effectie way to highlight the selected words
thanks
|
|
|
|
|
|
hi all,
this days ,i make Assemby ide , but i hae a probem with the resered words to be highlighted ,i want an effectie way to highlight the selected words
thanks
|
|
|
|
|
Hi all,
Just a quick question, I have a console application that I must launch and redirect output, so that I can parse its output. I am currenly using a Process object, setting the StartInfo.CreateNoWindow to true, not using ShellExecute and also redirecting standard output.
Under win2k+, no output window is displayed, under win9x/ME, an MSDOS window is displayed (for no reason, as output is already redirected to my application). So the DOS box has nothing in it.
So the question is...
Is there any way for me to get the DOS window to stay tucked away under win9x?
Any advice would be appreciated. Thanks.
--
Rob Hutchinson - Software Architect.
|
|
|
|
|
Windows and Windows NT are much different. Expect different behavior. In Windows (vs. Windows NT), the command shell works much differently (Windows is, after all, based on DOS). In Window NT, the console process can inherit settings - in a way - from the running application. This isn't so in Windows.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
So there is no way for me to remove that window?
--
Rob Hutchinson - Software Architect.
|
|
|
|
|
Maybe you could do a ::FindWindow() and minimize/hide it using the window handle..?
--
So let's just walk from place to place, as long as we don't talk face to face.
|
|
|
|
|
I didnt think of that, I'll give it a go.
Thanks.
--
Rob Hutchinson - Software Architect.
|
|
|
|
|
How can i build an own filedialog with a picture preview in C#?
|
|
|
|
|
Using Visual Stuido IDE i want to install A c# program. I need to create a setup such that:
if ie 5.0 or below is installed, it should update it silenty (of course promting to do so) and reboot the system and continue with setup again.
If operating system is 98 it should copy diffrent files and if it is 2000 it should copy diffrent files in the application folder.
Launch setup of some programs on the basis of the operatig system?
How can i do this? Please Help...
Regards,
Rahul.
|
|
|
|
|
|
Search for Installer class in google. It can perform all custom actions you want in youyr installer. There are some sample in http://www.c-sharpcorner.com/ [^]specially.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Hi,
How can I reach my graphic object boundaries on the clientrectangle? Is there a simple way of doing this? (I am doing this by creating a two dimensional matrix with the clientrectangle's height and width than giving every member of the array "0". After drawing some rectangle for ex:
Rectangle rect = new Rectangle(0,0,10,10);
Than I give "1" for every member of matrix with in the range of 0 to 10 . I mean I am tracking this after every drawing process.) Is there a simple way of this? And also if I didn't draw the object I can't guess the location and the area it used on the clientrectangle???
Thanx in advance
Cem Louis
|
|
|
|
|
hi
i am trying to detect the opened windows and to know the active windows from all opened windows .
So if anyone can help plz send me
thanx
|
|
|
|
|
You will need to wrap the EnumWindowsProc and take a look at EnumWindows or EnumDesktopWindows .
- Nick Parker My Blog
|
|
|
|
|
Hi,
I'm trying to add a new user to active directory,via LDAP.
I know the LDAP of the server,but what is the full path i have to give
For Example I want to add Tom to AD with LoginName "Tom" and Password "123456":
Directory Entry oDE=new DirectoryEntry ("LDAP://..."+???);
DirectoryEntries entries=oDE.Children;
DirectoryEntry NewUser=entries.Add("Tom", "User");
NewUser.Properties["FullName"].Add("Tom");
object obRet=NewUser.Invoke("SetPassword","123456");
NewUser.CommitChanges();
Regards,
Adi
|
|
|
|