|
Wow! ur so rad man! i'd nvr thnk 2 bing!
[NOTE THE JOKE ICON - the norm is to use google!]
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
|
Not that I use it myself, but: DataAdapter.Update
|
|
|
|
|
Your using your DataAdapter all wrong.
It should be declared outside the scope of the GetCustomers(), so it can be accessed by all the other functions, and you should be using it to Create/Read/Updated/Delete.
How To Update a SQL Server Database by Using the SqlDataAdapter Object in Visual C# .NET[^]
NOTE: the code below has not been tested / probably wont compile because i cant spell
your code should look something like this;
private SqlDataAdapter da;
private DataSet ds;
..... somewhere in your initialization code .....
da = new SqlDataAdapter("SELECT * FROM Customer_2", [YourConnectionString]);
da.UpdateCommand = [your update command];
da.DeleteCommand = [your delete command];
da.InsertCommand = [your insert command];
public void GetCustomers()
{
da.Fill(ds);
}
public void SaveChanges()
{
da.Update(ds, "[your table name]");
ds.AcceptChanges();
}
Then all you need to do is Create/Update/Delete all the rows you want in the DataSet, just make sure you call SaveChanges().
Thats how your supposed to use the DataAdapters.
But if you still want to use it in the way that you are using it, your going to have to loop through all the rows in the DataTable and check if their RowState == DataRowState.Changed (i think, could be updated), then just run your update command against SQL.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Kindly would you please help me code the whole thing because it is urgent and I still want to do it my own way. Please help it is emergency, my daughter is in hospital, I have loads of tension on my mind due to her.
<code> // Dont know if this is going to be accessed outside of the class
// If so you might want to make a wrapper property for it
private SqlDataAdapter da;
// Should contain your data
private DataSet ds;
..... somewhere in your initialization code .....
da = new SqlDataAdapter("SELECT * FROM Customer_2", [YourConnectionString]);
da.UpdateCommand = [your update command];
da.DeleteCommand = [your delete command];
da.InsertCommand = [your insert command];
// dont return anything here, just fill the dataset
public void GetCustomers()
{
da.Fill(ds);
}
// Saves all the changes to the database
public void SaveChanges()
{
da.Update(ds, "[your table name]");
// Accept the changes in the dataset
ds.AcceptChanges();
}
The following is the more code for deleting from my datagridview for removal not only from datagridview but also from database as well.
List<int>customerIDsToDelete = new List<int>();
private void btnDELETE_Click(object sender, EventArgs e)
{
// Iterate all the Rows in DataGridView Rows Collection
foreach (DataGridViewRow row in dataGridView1.Rows)
{
// Get the status of CheckBox in the current Row
bool deleteStatus = Convert.ToBoolean(row.Cells[0].Value);
// Get the CashierID of the Cashier in the current row
int customerID = Convert.ToInt32(row.Cells[1].Value);
if (deleteStatus)
{
row.Selected = true;
customerIDsToDelete.Add(customerID);
}
}
// Remove From DataGridView
foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(selectedRow);
}
// Remote From Database
DALHelper dal = new DALHelper();
dal.DeleteCustomers(customerIDsToDelete);
customerIDsToDelete.Clear();
// Load Cashiers from Database
LoadCustomers();
}
</code>
|
|
|
|
|
Sigh ... you are never EVER EVER going to get someone to write your project for you on here.
Regardless of your situation, sorry to hear, we all have our own problems and trying to play on our hearts is probably just going to piss more people off than anything.
I would "write" this code for you, but it seems Microsoft already has.
Case in point[^]
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
|
Go f*** yourself
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi,
I am facing a problem with GridViewExtension_Demo,the problem is that every time the page is being loaded the filter grid is shaking.
Please fix my problem as soon as possible and send me the report.
I am giving the URL from where I get GridViewExtension.
DataGrid with built-in filter functionality[^]
Piyali Chowdhury
|
|
|
|
|
Two things:
1) Try being a little more patient. Posting the same request every twelve minutes is a sure way to get people annoyed with you.
2) At the bottom of the article is a list of messages associated with just that article. Trt posting your question there; the author will then (probably) get an email describing your problem.
Remember (1) when doing (2)!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
???
You can download the source code, then you can fix it...
Try to contact the author...
|
|
|
|
|
ASk this question in the article's forum [at the bottom], that way you have more chance of a kidly response.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
I am facing a problem with GridViewExtension_Demo,the problem is that every time the page is being loaded the filter grid is shaking.
Please fix my problem as soon as possible and sent me the report.
Piyali Chowdhury
|
|
|
|
|
1) You are Rude and disrespectfull
2) We cannot do your job for you, you should be Fired with that attitude
3)In this Forum we help people who started something and get stucked, we don't do homework here
4) I wanted to swear at you , but i think the only thing i will do for you is to pray for you
God have mercy on you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
using c# to disable keyboard functions 2(or)x minutes, At the time of loading desktop.
(or)
disable the shortcut keys (Task manager,windows,Alt+Tab,Esc - all these) At the time of loading desktop.
After 2 minutes finished normal changes appearing for all.
Important : Anybody not able to create those top mentioned functions,used another way to give the code.
usage of project: i am security purpose to create it.It is protect copy of image typed files, and as boot partition files only.i am simply to create it.but i have no idea for this.
Anybody can help to create mentioned functions to send it. i am already posted my doubts but somebody answered,u try to create virus, malware something....
But i frankly told to for all,i don't think in my mind this type of creating. so i am repeat to briefly post my doubt.
|
|
|
|
|
Read the istructions at the top - how to get an answer.
No one is going to wade through that much unformatted code (use <pre></pre> to preserve your formatting) to see if they can work out what you are going on about.
Try cutting it down to a reasonable size (not umpteen pages)
Try using meaningfull names: menuItem14 is not as description as miStartInternetExplorer - again this make it easier for us to read.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hear hear.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Is "umpteen" even a word?
Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
'Fraid so...Umpteen[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
haha!
Regards,
Jason Pezzimenti.
|
|
|
|
|
What difference I see between using statement and Dispose/Finalize pattern is
- “Dispose/finalize” have upper hand if any object which implements this pattern and supporting different interfaces for different operations which performed on underneath unmanaged object, can take care of releasing that object even if user forgets to call dispose on that object
- However with “Using” statement, the scope of the using statement will be restricted to a single method, i.e. we will have to open the unmanaged object which will closed automatically by using’s finally block in the same method (which is, in most of the cases will not be feasible and efficient as we don’t do all the operation at a time on the unmanaged objects)
For Example:
1.Dispose/Finalize:
Suppose, we are using MS word COM to write doc files, we dedicate one class to do all the activities related to doc file and provide different interfaces to write to doc file like WriteTest() , InsertTable(), InsertImage(), …and so on . In this situation user will keep calling these interfaces according to their needs, and might forgets to close the word doc object. In this case, we can very well implement Dispose/Finalize pattern where finalize method will be act as back up plan to release unmanaged word doc object.
This approach will be efficient as long as we are using the same unmanaged object.
2.Using statement
Suppose, we are writing to a text file and we have interface to do this operation which takes text data and file name as parameter. In this case we can use “Using” statement to open the file and write data to it (again supposing that we will not any further operation on this file). What Using statement we do is it add try and finally block to this text file call. Which I guess efficient solution.
Hey guys, anybody know other differences other than what I mentioned here
Or you can correct me, If I am wrong in my above made conclusions!!!!
|
|
|
|
|
You basically have it in one. using is not a seperate pattern. It's a piece of shorthand that allows you to define an object, and AT THAT MOMENT, know that it will be cleaned up, so you don't need to go to the bottom and have a list of objects, and check that each has Dispose called on it. It's shorthand, to make code more readable and to make it clearer that you're not leaking anything. But, it only works when an object is in the scope of a single method.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: It's a piece of shorthand that allows you to define an object, and AT THAT MOMENT, know that it will be cleaned up, so you don't need to go to the bottom and have a list of objects, and check that each has Dispose called on it.
I liked how C++/CLI implemented this using Stack Semantics. You only need to write a destructor and compiler is smart enough to implement IDisposable on the type and ensure disposal when scope ends. IMO, it is much superior than using block.
|
|
|
|
|
You can't compare using statement and dispose pattern. using is just a syntactic shortcut which helps to call Dispose method. There is no efficiency difference in calling Dispose directly or wrapping in a using block.
Leaving disposable objects to finalization is inefficient. If the type can be disposed, you should take care about calling dispose on it once you done with the object.
It looks like you are confused with managing life time of objects.
|
|
|
|
|
@Navneeth
No,I am not confuse!! However I wanted to know more about it!!!
I just wanted to see if there are some other differences other than which I have mentioned!
I agree that using statement is not pattern and cant be compared with the Dispose/Finalize. However, if you think from perspective of reclaiming unmanaged objects from memory, then I am sure we can comapre them[as both do the same thing]
Apart from that, what exactly pattern? its only some set of standard which anybody can define( with some advantage), so saying something like this that Using is not pattern and cant be compared with Dispose/Finalize pattern will be a harsh!! isn't it?
I just posted this for discussion, which might be useful for people who do not know about these things.
Anyways thanks for your valuable reply from N a v a n e e t h and Christian!
|
|
|
|