|
Thanks, Jamie. Glad to have learnt something useful today.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
Hi, I can see from your code that when a user selects a date, you display it to him apsolutely 100% perfectly!! It will be formatted according to HIS/HER windows settings
This line is perfect!
TBDate1.Text = CAL1.SelectedDate.ToLongDateString();
However, take 1 step backwards:
DateTime selectedDateTime = CAL1.SelectedDate;
Without the .ToLongDateString() call, you have a DateTime Object.
The only place you went wrong below is that you tried to parse the string back into a Date, which at best is unnecessary and at worst will not work.
SqlConnection conn=new SqlConnection("my connection string");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Particulars WHERE DateField = @Date";
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Parse(TBDate1.Text);
The beauty of parameters (especially date ones) is that the ADO.NET provider will take care of any conversion for you... so change the last line to:
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = CAL1.SelectedDate;
simple, huh?
|
|
|
|
|
Hi,J4amieC.. Below is my code which i have changed.. But somehow when i run the program, the database does not show out when i click on the date. Is there's anything wrong or i still missing on some part??
DateTime selectedDateTime = CAL1.SelectedDate;
SqlConnection conn=new SqlConnection("my connection string");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Particulars WHERE DateField = @Date";
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = CAL1.SelectedDate;
Thanks for your help!!
Regards
|
|
|
|
|
I am now using Random r=new Random() to generate random number.
Now for debugging purpose, I want want my program to generate same random number every time i run it. I guess i need to use a fixed seed in order to do that. but i do not how. Can anyone please give me some suggestion?
Thanks
|
|
|
|
|
A quick search on MSDN:
public Random(int Seed);
Simply provide the same seed.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
I like to use windows shell icons in my program as menuitem icons. How can i include those without extracting them first and then import as resource?
EG:
I have a file menu and would like to have a blank page icon next to the new file entry.
To learn to fly the hard way, you just have to jump and to forget to hit the ground. The rest comes with it.
|
|
|
|
|
Use a program like the free IrfanView to extract icon images out of the shell icon library file (shell32.dll).
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
The question was, to do it without extracting them first.
Point is, that i have some example programs that do not have in included icons but show them in the menu. They aren't written in c# so maybe its something c# cant do, but i like to understand how it works.
Nothing is impossible, but to understand a woman.
|
|
|
|
|
Hi,
I am still new at C# and am coding an app that has tabs and on each tab is a treeview. I need to figure out which tab is selected and wich node on the treeview is selected for the current tab when the user clicks on certain menus.
I found a way to do it, but was wondering if there was an easier way.
TreeNode node;
string tabName = _tabs.SelectedTab.Text;
switch (tabName)
{
case "One" :
node = _tvwOne.SelectedNode;
break;
case "Two" :
node = _tvwTwo.SelectedNode;
break;
case "Three" :
node = _tvwThree.SelectedNode;
break;
}
Thanks in advance.
Sean
|
|
|
|
|
If you only have TreeView s on the tabs, you could use this code:
TreeView tv = ( TreeView ) tabControl1.SelectedTab.Controls[ 0 ];
TreeNode activeNode = tv.SelectedNode; Or, to get really terse:
TreeNode activeNode = ( ( TreeView ) tabControl1.SelectedTab.Controls[ 0 ] ).SelectedNode;
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
In reference to my previous post, you can use that code with TabPage s that have more than just the TreeView s on them. You just need to ensure that the TreeView is the FIRST control added to the TabPage .
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thank you. That works great.
Sean
|
|
|
|
|
Happy to hear it. Keep on codin'!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I have a binary data file saved as serialized object , when it is deserialized to datatable then binded to a datagrid , the user will make som changes to a record then save these changes back to the file , how can I save back the changed record ,do I have to serialize the all items each time when a one record updated , what is the right method to do so ,,, any help ;
thanx ........
|
|
|
|
|
|
leppie wrote: Yes, you have to 'overwrite' the old serialized object
Thank you, so what is the best way other than serializaion to deal with binary data files that been saved as blocks or records .
|
|
|
|
|
Hi, everyone, I'm new in this forum, I'm a question about if is posible when is run a program(update.exe) recall the program(update.exe), I'm desing a Update program but How can i close my update.exe when hava a new update of my exe and continue the process?
For your help thanks.
|
|
|
|
|
Search CodeProject or the web for "single instance application". There's some decent articles on CP regarding this, for example, here[^].
"Every technology has its detractors. I'm sure that somebody once stated that the pointy stick would never replace the fingernail as the fighting man's weapon of choice." Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Hi, I have a form that launches an external shockwave flash program and need to check, first, if the flash player is installed on the PC. Any ideas?
Thanks ahead!
radnix@hotmail.com
|
|
|
|
|
You check for the existence and validity of the HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ShockwaveFlash.ShockwaveFlash key and its subkeys.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thank you, I'll try it!
...of all the things I've lost, I miss my mind the most.
|
|
|
|
|
radnix, 't was my pleasure. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi,
i want to get the value of cell of selected row of listview control into TextBox.i hv got this by using the code as below.
for (int i=0;i < lstCorpname.SelectedItems.Count;i++)
{
txtAddressNo.Text=lstCorpname.SelectedItems[i].SubItems[0].Text.ToString();
txtname.Text=lstCorpname.SelectedItems[i].SubItems[1].Text.ToString();
}
but i think this is not the right way.
can u please give me another code.
Thank's
Regard's
Vikrant Singh
-- modified at 17:11 Wednesday 7th December, 2005
|
|
|
|
|
Hi
In a manual from a beamer i found following command data to switch the beamer to Power On.
02H 00H 00H 00H 00H 02H
What does this line means? Are this Bios Interupts?
I try to get this Data to the Beamer using System.Io.Ports.
But i don't know how. As a string? As a Byte?
System.IO.Ports.SerialPort sPort = new SerialPort("COM1", 38400, Parity.None, 8, StopBits.One);
sPort.Open();
sPort.Write( --> What? string? byte[]? char[]? <--)
sPort.Close();
Best Regards
|
|
|
|
|
How I can see what user open session in a computers of a domain (without Active Directory)?
Thank
Sory for my english.
|
|
|
|