|
Hi,
I have a DataGrid and two of the columns returned from the query are DateTime data types. I expect one of the columns to show just the Date while the other to have the Date and Time. However, the latter also shows only the Date. How do I fix this?
TIA.
-- modified at 20:50 Monday 16th July, 2007
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
In SQL, you may write like that
SELECT date1,date2 from YourTable
So, you can fix like that.
SELECT CONVERT(NVARCHAR(8),date,101),date2 from YourTable
then, you will get only date for 1st column without changing anything on UI.
|
|
|
|
|
Hi Michael,
I didn't realize it is to be done in the SQL script. This is exactly what I'm looking for. Big Thanks!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
It doesn't have to be done at the database, and it'd be far better not too, after all, why should the database care about data presentation?
Have a look at the BoundColumn.DataFormatString[^] property.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
I want to know how to add a web page to exciting project by using a maser page?
Thank you
|
|
|
|
|
first add new item to your existing project..and checked the checkbox select master page on bottom right..and choose your master page and your project in your masterpage..
if that answer can't help your question about..please do more specific
regard,
TCim
|
|
|
|
|
just add a new page in your project and while adding the new page it will ask for selecting the master page so by selecting your master page and then you can see the ne wpage which you want to create.
do your work in that new page.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
I have a class "testsupport" which does some stuff with my com port.
Another class "Tester" calls functions from testsupport class.
It calls DoSomething() which will start a timeout timer.
The timeout timer will generate a Exception if called. The timer works (I see log output), but my Tester class doesn't see the Exception?
What's wrong? My book O'Reilly Programming with C# 4th edition could not help me
Sebastian
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO.Ports;<br />
using System.Timers;<br />
<br />
<br />
namespace test<br />
{<br />
<br />
public partial class testsupport<br />
{<br />
private System.IO.Ports.SerialPort port;<br />
private Timer timeoutRecvTimer = new Timer();<br />
private Timer noMoreDataTimer = new Timer();<br />
<br />
public testsupport()<br />
{<br />
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);<br />
timeoutRecvTimer.Elapsed += new ElapsedEventHandler(timeoutRecvTimer_Elapsed);<br />
GC.KeepAlive(timeoutRecvTimer);<br />
}<br />
<br />
void timeoutRecvTimer_Elapsed(object sender, ElapsedEventArgs e)<br />
{<br />
timeoutRecvTimer.Stop();<br />
log.AddMessage("Timeout happened.", true);<br />
throw new System.TimeoutException("No data received, device correctly connected?");<br />
}<br />
<br />
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
port.Read(buffer, buffer.GetLength(0), port.BytesToRead);<br />
<br />
timeoutRecvTimer.Interval = 2000;<br />
timeoutRecvTimer.Start();<br />
}<br />
<br />
public bool DoSomething(int timeout)<br />
{<br />
... doing something here ...<br />
<br />
timeoutRecvTimer.Interval = timeout;<br />
timeoutRecvTimer.Start();<br />
<br />
return true;<br />
}<br />
<br />
}<br />
<br />
public class Tester<br />
{<br />
static int Main(string[] args)<br />
{<br />
try<br />
{<br />
testsupport testing = new testsupport();<br />
<br />
<br />
if (!testing.initComport())<br />
return 1;<br />
<br />
if (!testing.DoSomething(2000))<br />
{<br />
return 1;<br />
}<br />
<br />
while (true)<br />
{<br />
} <br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.Message);<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
}<br />
}<br />
|
|
|
|
|
Hi,
exceptions get thrown by some code, running on some thread; they are catched by the
first matching catch clause on that same thread when walking the thread's stack upstream.
Now Timers.Timer (and Threading.Timer) run their event on an internal thread, not yours,
so you wont catch any execption (unless you take special precautions, which I do not
fully master yet).
Forms.Timer events fire on the main (aka "GUI") thread; you can catch those in a
general try-catch in your static Main() method (not very useful inside your app,
since by then your app has almost exited anyway).
For what you want to achieve, you need another way to communicate back from your
timer event to the main thread, so you could do something on the GUI. You probably
want to use Control.Invoke (or set up an event that gets fired inside your timer event).
Hope this helps.
|
|
|
|
|
Hi Luc,
first a big thank you for your reply!
I had examples using Invoke, but I can't use them because I don't use a Forms applications (yet).
I want to create a dll which can be used by a gui or by a console application. In the first step only console...
I don't think that Invoke works with console app? But your hint with an custom event is helpful, I think, and I will try this out!
Thanks,
Sebastian
|
|
|
|
|
Events are the key. The easiest way to achieve what you want is to have the process working in a separate thread to raise an event when an exception occurs. This could be smart enough to Pass the Exception raised in the EventArgs of the event.
This way, whatever is consuming your threaded API can decide what they want to do on an exception within the thrteaded process. If this is a forms app, it will likely use InvokeRequired and Invoke to show a message on the UI. For a Console App you can just Console.Writeline your error without using any equivalent to Form.Invoke
|
|
|
|
|
Gnaarf I cant get it to work
I subscribed to the event fired on timeout timer in my main():
<br />
sample.OnTimeout += TimeoutHandler;<br />
static void TimeoutHandler(object gh615, TimeoutEventArgs e)<br />
{ throw new System.TimeoutException("Command failed: " + e.timedOutCmd + " Device did not respond."); }<br />
The event fires, but the throw is still not effective in the main function.
Again for summarisation of my problem:
- A class sample owns a timer timeout1
- A class testing which has the static void main() should get informed when the timeout occurs and should stop processing (for example while(true) loop)
I think I need an example... Anyone?
Sebastian
|
|
|
|
|
I had a dll that was being created by tlbimp from a com component. However these dlls had no versioning info.
So I used this:
http://blogs.msdn.com/ianhu/archive/2005/06/16/429903.aspx
to add versioning and it worked.
However now my applications aren't finding the library in the gac. (I have to drop in the output folder of the application).
What could be going on here?
In the assembly my dll shows up as
MyLibrary 1.0.0.0 119e4efc79848a50 MSIL
The version is incorrect but it gives the correct when right clicking and checking in properties/version.
119e4efc79848a50 is the PublicTokenKey
and MSIL (under column 'processor architecture) is new (the library before adding versioning didn't have this).
When I run an application I get this:
=== Pre-bind state information ===
LOG: DisplayName = MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=119e4efc79848a50
(Fully-specified)
LOG: Appbase = file:///E:/Program Files/Test/MyApp
LOG: Initial PrivatePath = bin
Calling assembly : MyApp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file (E:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet.config).
LOG: Using machine configuration file from E:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=119e4efc79848a50
Thanks,
Mike
|
|
|
|
|
I Have A Problem in Removing white spaces between letters in single string word which retrieved from sql data Base
thanks ,
Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
Care to give an example? What is the string from the DB? What should it look like? What have you tried?
Hogan
|
|
|
|
|
Thank You snorkie For Your Response
Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
If you just want to remove all whitespaces...
private string StripWhitespace(string input) {
return input.Replace(" ", "").Replace("\t", "").Replace("\n", "");
}
If that's not what you're after, you'll have to be more specific.
|
|
|
|
|
Thank you BonSoft For Your Help , Your Code Works With me and solve the problem
Thanks
Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
I have created a user control with "overridden" ForeColor and BackColor properties. When I place the control into a new project, I can change the colors. However, when I run the project the colors go back to their default values. I know that you can add the color changes into the InitializeComponent section of the new project, but I was wondering if you could change which properties will show up in the InitializeComponent section. For Example:
//This Shows up in the InitializeComponent section when I place my component into the new project
this.fileSelect1.Location = new System.Drawing.Point(32, 24);
this.fileSelect1.Name = "fileSelect1";
this.fileSelect1.Path = "C:\\Documents and Settings\\davis\\My Documents\\Visual Studio Projects";
this.fileSelect1.Size = new System.Drawing.Size(648, 40);
this.fileSelect1.TabIndex = 0;
This is what I want:
this.fileSelect1.Location = new System.Drawing.Point(32, 24);
this.fileSelect1.Name = "fileSelect1";
this.fileSelect1.ForeColor = Color.Black;
this.fileSelect1.BackColor = Color.White;
this.fileSelect1.Size = new System.Drawing.Size(648, 40);
this.fileSelect1.TabIndex = 0;
Thanks in advance for your time.
|
|
|
|
|
You have to tell the class which properties to expose to the Desginer so that it can write the code to set these property values. Check out the DesignerSerializationVisibilityAttribute:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int SomeProperty
{
get
{
return _someProperty;
}
set
{
_someProperty = value;
}
}
|
|
|
|
|
Thanks for pointing me in the right direction. I have it working now.
Chase Davis
|
|
|
|
|
i am working on a network base installer,my project check for a specific software whether installed or not on a client machine, if not installed i hav to install it remotly, i am having problem in copying a file to a remote (pc i.e client)and then executing the setup from tht location.
|
|
|
|
|
So, you spammed the forums with this post before, then you ignored the replies. I, and someone else, already told you to look into the File class. You also have to brush up on Windows Networking and Folder Shares.
You choose to ignore the previous answers and post the question again. Are you going to ignore the very same answers again too??
|
|
|
|
|
i want the help regarding wrting the research proposal
|
|
|
|
|
Would you please care to tell us wtf this has to do with C#?
Thank you for your cooperation.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|