|
I found the asp.net answer, but it can't be applied to c#. Anyone know of a way to do this without creating a 2nd dataset to store it in?
|
|
|
|
|
|
You can hide those columns through the datagrid properties
|
|
|
|
|
H:\AllBrite\AllBrite\Form1.cs(3702): 'System.Windows.Forms.DataGrid' does not contain a definition for 'Columns'
using framework 1.1...
|
|
|
|
|
In our app am showing SQL exception being thrown to user (I know its not a good practice, but the scenario is different). It is always in English, any thoughts how to localize?
Thanks.
|
|
|
|
|
If you simply want SQL Server error messages shown with a different laguages, perhaps the easiest way is to use SET LANGUAGE (Transact-SQL)[^].
It also affects literal dateformat, but it can be changed after changing the language. In SQL Server 2005 and 2008 there are 33 different languages, refer to: sys.syslanguages (Transact-SQL)[^].
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
My context is , am catching he exceptions thrown from sql server in c# app and throwing as is. So, are you saying that to first launch "Set Language" statement from c# app before performing any SQL actions and that will throw localized exception messages?
|
|
|
|
|
Yes that's the idea. If I execute the following:
SET LANGUAGE Italian
SELECT * FROM NonExistingTable
The result is:
Msg 208, Level 16, State 1, Line 2
Il nome di oggetto 'NonExistingTable' non è valido.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
thanks Mika, i will try that.
|
|
|
|
|
You're welcome.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I've only just started looking at Pointers and all that memory address changing and I want to be able to specify what address i want to change like 0023ff7c
Is this possible or have i completely got the wrong idea what pointers can do?
ta
|
|
|
|
|
That depends on what you think you can do with it. Yes, you can have a pointer look at any pipece of memory. No, you can't just poke anything you want, wherever you want. Also, from your applications point of view, it's the only app running on the machine, besides Windows. You can't just poke a byte into an arbitrary address and expect another application to see the change. It doesn't work like that.
|
|
|
|
|
thanks i don't realy get all this pointers buisness
i'll just give up and not do any more
|
|
|
|
|
Dave Kreskowiak wrote: poke
Ah, I remember the poke keyword on the old Commodore Basic, on the Apple ]['s as well. Used to always kind of snicker about it ( SB material creeping in )...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Please help me again.
This is the weak dictionary i have created. It is compiling correctly. But when i test it with GC.Collect(), i can still refer to the weak reference values even after calling GC.Collect() method. How is it possible? What is wrong in my code.
namespace TryWeakDictionary{
public class WeakReference<T> : WeakReference {
public WeakReference(T val)
: base(val, false) {
}
}
public class WeakDictionary<TKey, TValue> : IDictionary<TKey,TValue> {
private Dictionary<TKey, WeakReference<TValue>> weakDictionary = new
Dictionary<TKey, WeakReference<TValue>>();
public void Add(TKey key, TValue value) {
WeakReference<TValue> weakRef = new WeakReference<TValue>(value);
this.weakDictionary.Add(key, weakRef);
}
public void Clear() {
this.weakDictionary.Clear();
}
public bool ContainsKey(TKey key) {
return this.weakDictionary.ContainsKey(key);
}
public void Remove(TKey key) {
this.weakDictionary.Remove(key);
}
public bool TryGetValue(TKey key, out TValue value) {
WeakReference<TValue> weakReference;
if (this.weakDictionary.TryGetValue(key, out weakReference) &&
weakReference.IsAlive) {
value = (TValue)weakReference.Target;
return true;
} else {
weakDictionary.Remove(key);
value = default(TValue);
return false;
}
}
}
}
|
|
|
|
|
This is the idea of weak references. Citing MSDN:
"A weak reference allows the garbage collector to collect an object while still allowing an application to access the object. If you need the object, you can still obtain a strong reference to it and prevent it from being collected."
Your code is OK.
EDIT: I have tested your code and it works as expected. How did you make youre tests?
Like this?
static void Main(string[] args)
{
TryWeakDictionary.WeakDictionary<int,> wd =
new TryWeakDictionary.WeakDictionary<int,>();
for (int i = 0; i < 100; i++) {
wd.Add(i, new C { Data = "abc" });
}
GC.Collect();
C v;
if (wd.TryGetValue(0, out v))
Console.WriteLine(v.Data);
Console.WriteLine("End");
Console.ReadLine();
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
modified on Tuesday, November 18, 2008 1:25 PM
|
|
|
|
|
There is nothing wrong in your code. Calling the GC.Collect method doesn't guarantee that all objects that can possibly be collected are collected. The garbage collector still decides what to collect and if there is any reason to do any collection at all.
You should shadow the Target property in the class, so that you don't have to cast it when you use it:
public class WeakReference<t> : WeakReference {
public WeakReference(T val) : base(val, false) {}
public new T Target { get { return (T)(base.Target); } }
}</t>
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Once again, thank you very much. Its all due to my misunderstanding that when i use GC.Collect, GC forcibly collects all objects....
|
|
|
|
|
I want to learn my computer name or others computer name. How can I do it? Could please you tell me how I can do it?
|
|
|
|
|
You can use Environment class.
|
|
|
|
|
I found it. the code is System.Environment.MachineName
|
|
|
|
|
I am transfering a very large file through the web service. So, does web service needs to know about the file size? If so, what is the default limit size.
|
|
|
|
|
Web Services are not supposed to be used for large files. Best to use the web service to give a URL and then d/l from http.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
|
Thanks for answering though.
But what should be the default executionTimeoutInSeconds if i were to set 100MB file size limit. Microsoft web site had 400MB and 300 second set. Do i just take a half of 300 seconds or is there any kind of formula.
<pre>Microsoft website
<httpruntime maxmessagelength="409600" executiontimeoutinseconds="300" />
my web.config
<httpruntime maxrequestlength="100000" /></pre>
|
|
|
|