|
Hi everybody:
I use the following code to display the data in a DataGrid Control:
OleDbConnection con = new OleDbConnection(StrConnectionString);
ad=new OleDbDataAdapter();
ad.SelectCommand = new OleDbCommand(strSQL, con);
OleDbCommandBuilder custCB = new OleDbCommandBuilder(ad);
DataTable tbl=new DataTable("Domains");
ds=new DataSet();
ds.Tables.Add(tbl);
ad.Fill(ds,"Domains");
tbl.PrimaryKey=new DataColumn[]{tbl.Columns["CategoryId"],tbl.Columns["DomainUrl"]};
dv=new DataView(tbl);
Grid.DataSource=dv.Table;
it works fine.
and after that I use
dsTmp=ds.Copy();
make another copy of the data and make some change to the dsTmp.
then I save the data back to db and refresh the Grid control by using:
BindingManagerBase bm=BindingContext[dsTmp,"Domains"];
bm.EndCurrentEdit();
ad.Update(dsTmp.Tables["Domains"]);
dsTmp.AcceptChanges();
RefreshDomains();
dsTmp.Clear();
refresh:
ds.Clear();
ad.Fill(ds,"Domains");
since I don't want the user see the middle result of the data change so I use dsTmp to hold the data and make the change. if I have less data, such as 100 rows or less, the code works very well. But if I have lots of data (1 million rows), there is an exception comes out,and the grid can not be drawed. even I just update 2 rows of the 1 million rows.
also cause the exception happens at the "paint event" (I guess), I can not see which line of code cause the problem!
Does anyone has an idea about it?
Thanks a lot!
Alan shen
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Is there a way to read an XML file into a dataset with the same format as a .config file? Config files are formatted as such:
<configuration>
<appsettings>
<add key="Clear" value="true">
Is there a way to read an XML file into my program using such keys and values? Thanks in advance.
D
|
|
|
|
|
I've never tried anything like this before.
My aquantance has written an exe file which performs certain tasks in C++. It gets data and performs some very complex algorithms on it to produce certain values.
It's written as a DLL and an EXE right now.
It's not a problem for him to modify the code in whatever way I need.
How can I pass values between my C# application and his C++ application (or DLL).
I'm looking for some VERY basic starting information.
Thanks!
If you have time and feel like contacting me directly, my AIM name is navinineteen.
|
|
|
|
|
|
I'll start reading. Thanks.
|
|
|
|
|
Hello
I have a board that connected to computer with usb port.
now i want to send data to board and recieve data from it.
do you have any library or function to communicate with usb port using C#.net ?
Thanks for your help.
|
|
|
|
|
I am not sure this is possible but here it goes...
I am wondering if there is any possible way for a base class to detect when the inheriting classes changes the value of it's property? My base class does not contain this property since it will it is part of the inheritting classes implementations. Basically, I want the inheriting class to set a value in the base class to signify a change without implementing and other code( except for attributes ) outside of the base class that it will inherit.
any ideas?
|
|
|
|
|
Well what we use all the time is a basic 'Dirty' property in the base class. That way we can tell if we need to serialize the class at all. This is the basic premise for the standard 'You have made changes, do you want to save?' logic. I hope that I am reading your question correctly.
|
|
|
|
|
Basically I want to allow a developer to create whatever properties they need for there data structure. Whenever the value of any of these properties are changed, then it would set a value in the base class to signify that a value needs to be changed. I want to try and keep them from having to code in the flag change. Not of the properties using in the base class with ever be of the properties they create for their data structure that implement the base class.
|
|
|
|
|
Have your base class maintain 2 copies of it's base values and a thread that periodically compares the two and sets the flag if one is changed.
|
|
|
|
|
I have tried DTE, but I still cann't solve my problem.
Can Someone give me a solution?
-- modified at 11:49 Monday 3rd October, 2005
|
|
|
|
|
Hi,
Following is the senario.
I have an Windows Service having multiple threads running and performing their task , also put their status in database.
I have an another ASP.NET based application which gets the status from the Database of each thread and displays the results.
I want is if user goes in ASP.NET application and click the Thread1 to be aborted which is running in Windows service then how can I terminate it ?
Please help any suggestion or ideas.
Regards,
Nitin.
Nitin R
|
|
|
|
|
I wonder why you wouldn't want to do it? Aborting a thread is usually a very bad idea. If you have to do it, you might want to use remoting. Make the service host an object, access the object in your ASP .NET app, and call a method on it to abort the thread.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks Senthil,
The thing is I have to abort the thread when user command so..
Can you give me an example of it.. how do I create a object of the thread selected by the user.
|
|
|
|
|
hi,
i dave developed a .net component that is working fine in dot net projects but i want to add this component to a vb 6.0 project for that i have assigned strong name to the project but following problem is hindering
i am using some activex components (one of them is Microsoft.Scripting and other is thirdparty component) in my dotnet component, and i am not able to assign any string name to these components,
what should i do to make my component workable with vb 6.0
regards,
Arus
-- modified at 10:53 Monday 3rd October, 2005
|
|
|
|
|
Hello,
I have a select statement:
<br />
DataRow[] belowRow = this.dataview.Table.Select("Description = Stage "+stageNumber+" Value");<br />
where stageNumber is the integer.
I get the Missing Operator error message when trying to execute the select statement. Any ideas?
Thank you.
|
|
|
|
|
Are you trying to put together a string value in the condition?
DataRow[] belowRow = this.dataview.Table.Select("Description = 'Stage "+stageNumber+" Value'");
---
b { font-weight: normal; }
|
|
|
|
|
Hi for all
I've readed the Dominique Bijnens' article "Background applications listening for keyboard activity" that explains how to read the keyboard even in background. There are some pieces of code that I didn't understand. Dominique explains that the KeyHandler function will be called when a key is pressed of the keyboard. What I didn't understand is when and where the static constructor of the KeyboardListener class is called. Below some pieces of code of their article.
Please, who have a little(or a lot) bit of patience answer this question for me.
Thanks a lot for help
private static void KeyHandler(ushort key, uint msg)
{
if(s_KeyEventHandler != null)
{
Delegate[] delegates = s_KeyEventHandler.GetInvocationList();
foreach(Delegate del in delegates)
{
EventHandler sink = (EventHandler)del;
try
{
// This is a static class, therefore null is passed as the object reference
sink(null,new UniversalKeyEventArgs(key,msg));
}
// You can add some meaningful code to this catch block.
catch{};
}
}
}
#endregion
#region Public declarations
///
/// An instance of this class is passed when Keyboard events are fired by the KeyboardListener.
///
public class UniversalKeyEventArgs : KeyEventArgs
{
public readonly uint m_Msg;
public readonly ushort m_Key;
public UniversalKeyEventArgs(ushort aKey, uint aMsg) : base((Keys)aKey)
{
m_Msg = aMsg;
m_Key = aKey;
}
}
///
/// For every application thread that is interested in keyboard events
/// an EventHandler can be added to this variable
///
public static event EventHandler s_KeyEventHandler;
#endregion
#region Public methods
static KeyboardListener()
{
ListeningWindow.KeyDelegate aKeyDelegate = new ListeningWindow.KeyDelegate(KeyHandler);
s_Listener = new ListeningWindow(aKeyDelegate);
}
|
|
|
|
|
The static constructor of a class is called whenever this class is used for the first time, where 'using' may be access to some static field, property or function or instantiation of it.
In this case I would assume that it is called when someone binds the s_KeyEventHandler event.
You can easiliy find it out by yourself: Set a breakpoint into the static constructor and if the program breaks there just look into the stack trace.
|
|
|
|
|
Thanks Robert, now I understand. I didn't know that static constructors was called when the class is used.
|
|
|
|
|
There is no culture specified for (Amharic) ethiopia
but i've used the affrikans culture to fit my needs by customizing the properties
now i wanted to use the DateTimeFormatInfo to change the way my dates looked on the
app and to have it a local feel i inherited from the System.Globalization.Calendar class
to make my own EthiopianCalendar class. But the propblem is i can not assign
this class's instance to the Affrikans culture in stance DateTimeFormatInfo property.
I tried to have a new writeble instance for the DateTimeFormatInfo but setting the caelndar
property results in InvalidOperationException i think caelndars can not be assigned if they
are not listed in the optional calendars list.
But why did microsoft made the Calendar class abstract, there is no use in inheriting
from this class if we can't set it to a DateTimeFormat.Calendar property, or we have to write our own
class that implements IFormatProvider like DateTimeFormatInfo (that's sad) ????
Is there any way to get around this ??
I've asked this question before but no one was able to give me an answer. if u can ....
-- modified at 10:25 Monday 3rd October, 2005
|
|
|
|
|
I need to convert a string made up of date/time + 9 digit number in to hex value then into a string...any ideas ?
i.e.
convert "20050910120013123456789" into Hex string equivalent
|
|
|
|
|
I think this could work!
1st:
Convert the string into Int64;
string datetimestring;
Int64 datetimeint64 = Convert.ToInt64(datetimestring);
2nd:
Convertion to Hex, by using this Method:
string hexstring = IntToHex(datetimeint64);
public string IntToHex(System.Int64 number)
{
return String.Format("{0:x}", number);
}
Hope it works!
Good luck,
Martin
-- modified at 10:23 Monday 3rd October, 2005
|
|
|
|
|
I've tried that but the number is too large to convert to a Int64
i.e.
string sTemp = DateTime.Now.ToString("yyyyMMddHHmmss")+"123456789";
Int64 iTemp = Convert.ToInt64(sTemp);
Throws exception......
|
|
|
|
|
Would a Decimal work? It has an integral range of 2^96 bits
|
|
|
|