|
Hello !
I have a question about DB specifications :
Do we have to call IDbCommand.Dispose ?
What does IDbCommand.Dispose mean?
We have problem doing this :
<br />
IDbConnction pipe = new OleDbConnection(connString);<br />
IDbCommand command = pipe.CreateCommand();<br />
command.QueryString = "select ...";<br />
IDataReader reader = command.ExecuteReader();<br />
command.Dispose();<br />
reader.Close();<br />
pipe.Close();<br />
The problem get solved if we don't do IDbCommand.Dispose
Your comments would be very helpful. Thanks.
Sovann
|
|
|
|
|
You cannot Dispose Command Object after ExecuteReader Method, the datareader object maintains the connection to the database as it will not pull all data at once, and it will pull data record by record. So dispose the command object after getting all the data.
Naveen G
MCSD.Net
|
|
|
|
|
Thank you. Anyway, do we have to call IDbCommand.Dispose ?
|
|
|
|
|
Whenever a class exposes a Dispose method you should definitely call it as it frees resources immediatly. You can take advantage of the using statement that automatically calls Dispose on an object when execution leaves its scope. Simple example taken from MSDN.
using (Font font1 = new Font("Arial", 10.0f))
{
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you. Your comment has been very helpful
|
|
|
|
|
Hi all,
i just want to know how to trim away the last part of a string in a variable...
I have the following:
string strNum = "0821234567,0721234567,0831234567,"
string strNum2 = "";
if(strNum.EndsWith(","))
{
<How Do i trim the last character away? I just need to get rid of the "," at the end>
}
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
You create a new string from the part of the string that you want to keep:
strNum = strNum.SubString(0, strNum.Length - 1);
---
b { font-weight: normal; }
|
|
|
|
|
Thank you for your time...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hmm, you should consider using "Trim" or "TrimEnd" instead of "Substring" - after all, you want to - well - trim
It will save you the clumpsy "if" construction as well.
|
|
|
|
|
Thank you, the first one worked. so after i checked if there is a "," at the end of the string it just leaves it out. but i'll use the trim end next time. thanks.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
On another note, something faster, and optimized than substring or trimending
(think what shall happen calling substring on a very huge string?)
strNum[strNum.Length-1] = string.Empty;
There are few scenarios where this will be the best and others where this wont be a better idea.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Two problems with your code:
strNum[index] is a char. string.Empty is a string. You can't assign a string to a char.
Strings can't be changed. Hence strNum[index] is a read-only indexer.
So I do not see how this should work. Using a StringBuilder might help if the strings are repeatedly modified, but for a single trim operation it would not make any sense.
|
|
|
|
|
I'm try to write my own picture viewer using the MDI format.
Have the basic setup done.
Need help on how to load a picture/image into the active ChildMDI form.
Do you load the picture/image into a picturebox or something else.
Thanks,
Steve C#freak
|
|
|
|
|
Easiest way is to load it into a pictureBox. You can do something like:
Image image = Image.FromFile( "c:\\blah.jpg" );
pictureBox.Image = image;
My pointless rants
http://meragussa.blogspot.com
|
|
|
|
|
Thanks for the help.
I'm trying to load the image into the activeChild.
Do not know how to go about this.
eg; select open image from the MdiParent, and have it open in the active MdiChild form.
Greatfull for all comments/Help given.
Thanks
Steve C#freak
|
|
|
|
|
In the main application which is the parent of all MDI Child form do something like
((MyMdiForm)this.ActiveMdiChild).SetImage( image );
ActiveMdiChild will get you the active mdi child. You need to make sure your MDI child supports a Method to accept an Image or file path to an image.
In MyMdiForm.SetImage( Image image );
Do something like:
pictureBox.Image = image;
|
|
|
|
|
Acctually I have one radio server.when I connect that server from Windows Media Player it is not connecting,but it is working fine for apple Itune and Quick time player,can anyone tell me why is it happening?Do i need to do some special settings in Media Player????
nishu
|
|
|
|
|
Are you trying to connect using C#, or have you posted this in a completely irrelevant message board?
---
b { font-weight: normal; }
|
|
|
|
|
My Server is in c# only!!!
nishu
|
|
|
|
|
hi all,
posted this (similar to) yesterday and didn't stir anyones reflection juices, so i worked on it some more and hopefully i am gettign closer.
I want to, given a control, and an event, find it's addEvent's delegate's parameters. More specifically teh second (usually) that extends (usually again) EventArgs .
this is my code so far. please see comments inside foreach loop
private void RegisterControlEvent()
{
Control control = this.NamingContainer.FindControl(ControlTrigger);
if (control == null) { return; }
string eventName = ControlCoverter.GetEventName(control);
if (eventName == string.Empty) { return; }
EventInfo ei = control.GetType().GetEvent(eventName);
ParameterInfo[] param = ei.GetAddMethod().GetParameters();
Type type = null;
foreach (ParameterInfo p in param)
{
type = p.Member.DeclaringType;
}
if (type != null)
{
MethodInfo mi = this.GetType().GetMethod("GenericControl_TriggerEvent");
MethodInfo constructed = mi.MakeGenericMethod(new Type[] { type });
Delegate del = Delegate.CreateDelegate(ei.EventHandlerType, constructed);
ei.AddEventHandler(control, del);
}
}
public void GenericControl_TriggerEvent<T>(object sender, T e)
{
.
.
.
}
am I approaching this completely the wrong way ?
kind regards,
g00fy
|
|
|
|
|
I know it's not a finished product, but they are calling it RC, so it should be close to finished.
Anyway, in the .NET 2 framework, a main window was separated into well known areas such as status bar area, toolbar area, document area, etc. I see nothing of that now. Have I totally missed something, or am I supposed to sit and tweak stuff like that "by hand"??
--
Torn from tomorrow's headlines
|
|
|
|
|
Hi Jorgen
I'm not too familiar with WPF just yet, but a quick search turned up this post[^] that talks about the different positioning techniques available in the WPF toolkit.
|
|
|
|
|
Thanks for the link! I'm sure there must be some "idioms" for creating "old school" GUIs. I tried using some of the layout stuff, but buttons and whatnot I put in it, just wouldn't render. I admit it's late, I'm tired, and have a fever. Maybe I'm just delerious?
--
Torn from tomorrow's headlines
|
|
|
|
|
Believe me, it's not easy. I've been 'playing' trying to create a user control that mimics an Outlook navigation pane and so far it's taken me 2 weeks to just get the layout 75% right.
Trying to do layout in code (C# or XAML) is long winded and error prone. Which leaves the VS Designer which seems far from finished.
|
|
|
|
|
I wrote recursive function where i need to pass array of integer and output a collection of arraylist in main
Below is how i did but how can i change my program
to out put recive a arraylist and print out in main
Please help
Thankyou
public class PermutationsLex
{
[STAThread]
static void Main(String [] args)
{
int [] a=new int[] {3,4,2};
ArrayList sa= Permute(a,0,a.Length-1);
Console.ReadLine();
}
static ArrayList Permute(int[] a, int start, int finish)
{
System.Collections.ArrayList permutationsList= new System.Collections.ArrayList();
if (start == finish)
{
// for (int i = 0; i <= finish; i++)
// {
// Console.Write(a[i] + " " );
// }
// Console.WriteLine("");
}
else
{
for ( int i = start; i <= finish; i++)
{
swap(a,start,i);
Permute(a, start+1, finish);
swap(a,start,i);
}
}
}
public static void swap(int[] a, int i, int j)
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
|
|
|
|