|
yes change the form border style
|
|
|
|
|
Hello
I am want to query a database in my book table. I want to find all the books that are over due. This is the query below, but when l execute it, it returns no records. I think it is because of the datatype. I am using MS Access in the datadue field l have it set as a DateTime datatype.
I am using C#
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < '" + today + "' ";
Does anyone know how to correct this query so that it will return the books that are overdue.
Many thanks in advance,
Steve
|
|
|
|
|
Try using some function which is equivalent of To_Date function of oracle.
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < To_date('" + today + "' " + ", yyyy/mm/dd");
|
|
|
|
|
just checked the access syntax. the below should also do.
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < " + today + ";
Another solution:
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < Format(" + "'" + today + "', 'YYYY/MM/DD') ";
Do reply whether it could solve your problem or not.
|
|
|
|
|
Here's my code, designed to query a definition from dict.org (ironically, there are only a handful of Windows programs out there that do that):
**************************
IPHostEntry IPAdd = Dns.Resolve("dict.org");
IPEndPoint IPEP = new IPEndPoint(IPAdd.AddressList[0], 2628);
Socket s = new Socket(IPEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
string str = "DEFINE * " + Convert.ToChar(034) + SelectedWord + Convert.ToChar(034) + Convert.ToChar(013) + Convert.ToChar(10);
Byte[] Sender = System.Text.Encoding.ASCII.GetBytes(str);
Byte[] Receiver = new Byte[20000];
s.Connect(IPEP);
Int32 bytes = s.Receive(Receiver, Receiver.Length, 0);
s.Send(Sender, Sender.Length, 0);
bytes = s.Receive(Receiver, Receiver.Length, 0);
strDefinition = System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes);
************************
My problem is, every so often I get a response that is so long it overflows my Receiver array (ever look up "at" in the dictionary? ). Declaring a 1,000,000 member array seems a bit silly, so is there a way to declare a dynamic Byte array that can be added to like an ArrayList? Or maybe some other workaround for this algorithm?
|
|
|
|
|
tantiboh wrote:
My problem is, every so often I get a response that is so long it overflows my Receiver array (ever look up "at" in the dictionary? ). Declaring a 1,000,000 member array seems a bit silly, so is there a way to declare a dynamic Byte array that can be added to like an ArrayList? Or maybe some other workaround for this algorithm?
Something like this:
StringBuilder sb = new StringBuilder();
while ((bytes = s.Receive(Receiver, Receiver.Length, 0)) != 0)
{
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
}
strDefinition = sb.ToString();
Yes, even I am blogging now!
|
|
|
|
|
It's an interesting approach. Apparently, GetString doesn't like it when bytes hits zero, so I rewrote it like this to prevent a lock-up:
*************************
Byte[] Receiver = new Byte[150];
System.Text.StringBuilder sb = new System.Text.StringBuilder():
Int32 bytes = s.Receive(Receiver, Receiver.Length, 0);
do
{
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
}while ((bytes = s.Receive(Receiver, Receiver.Length, 0)) == 150);
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
strDefinition = sb.ToString();
**********************
The problem I'm encountering now is that the algorithm doesn't wait until all the data is retrieved before it starts processing it. Is there a way to stop the program until all the data is received? How does the program know that the sender has finished sending data?
|
|
|
|
|
Hi all,
I try to write to a Form1 class which extend a window Form class, and serves
as the base class for another class Form2(not extend Window Form class) (i.e. Form2 extend Form1).However, when I try to use the VS.net Form designer for putting control on the Form1, I got errors. Why ?
Thanks
|
|
|
|
|
Hi,
If you could list the type of errors you are getting, it will make it easier for us to help you. Also, a quick code snippet never hurts.
~javier lozano
(blog)
|
|
|
|
|
Sorry
In fact,
I write 2 form class
one entitled "class Form1 : System.Windows.Forms.Form"
another entitled "class Form2 : Form1"
How do I use the VS .Net Form designer to design form2?
Thanks
|
|
|
|
|
Hi,
I am wondering whether it is possible to open and run or run a matlab program from an interface developed in c#.
I mean i have a matlab xyz.m file which runs directly, when u type at matlab interface command prompt. Can we automate it by doin tht directly from an interface developed in c#?
thanks in advance,
Suman.
Suman
|
|
|
|
|
Matlab is in C, isn't it ? To run it in C#, MC++ or COM are probably your only hope.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi Graus,
yeah Matlab is developed in C, but i need to run matlab program directly from C#.
BTW how to use MC++ or COM in implementing this type of applications. I mean can u gimme an example of a simple program.
Thanks,
Suman.
Suman
|
|
|
|
|
|
I'd like to affect specific items in a List Box. In other words, I'd like to take any one (or more) elements of the List Box Collection and, say, turn it red, or turn it bold.
Anybody know how to do this?
|
|
|
|
|
|
|
winForms - C#
This should be simple. Does the richtextbox control support dragging and dropping?
I know of the DoDragDrop method. It doesn't help me if I can't interrogate the system to find out what the mouse is actually dragging.
I've written a bunch of custom event handling to deal with this, but the last thing I'm missing is the event arguments you would normally get in a DragEventHandler. And short of changing the signatures on delegate event handlers (doesn't work, obviously), I'm not sure how to get the mouse args.
Is there any easier way to do this? Does the RTB actually support easier DND capability?
Thanks in advance.
|
|
|
|
|
Yes, it is supported. Search MSDN, in particular, try here[^].
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
Hi all,
Are there any references for writing a scalable server application ?
I searched on internet but find nothing, just can find some
product info on scalable server application.
Thanks
|
|
|
|
|
|
|
Hi,
I wrote a little C# program that should be able to catch messages to a window from a 4GL application and change the default behaviour.
I struggle with the repaint of an icon. It gets painted on the frame by my dll, and repainted if I move another window with the mouse over it. But if I overlay the window with another one and click on 'minimize' the icon does not get repainted. If I look with spy++ I see WM_ERASEBKGND being fired, my C# PaintExtras method is executed. Any idea how to solve this? I copied the C#-code below. It is a little different then the code I posted a couple of days before.
As a sidequestion: how do I dispose this dll from memory after I have done with it?
Regards,
Stefan.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class GenericWindow : NativeWindow
{
public const int WM_ERASEBKGND = 0x14;
private const int GWL_WNDPROC = -4;
private IntPtr oldWndProc = IntPtr.Zero;
private Win32WndProc newWndProc = null;
private int widgetH;
#region Imported User32.DLL functions
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int GetDC(int hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ReleaseDC(int hWnd,int hDc);
[DllImport("User32.dll")]
private static extern int DestroyIcon(int hIcon);
[DllImport("user32.dll")]
public static extern int DrawIcon(int hdc, int x, int y, int hIcon);
[DllImport("user32.dll", EntryPoint="CallWindowProc")]
private static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr
hWnd, int Msg, int wParam, int lParam);
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int ExtractIcon(int hInst, string lpszExeFileName,
int nIconIndex);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex,
Win32WndProc newProc);
[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
#endregion
// A delegate that matches Win32 WNDPROC:
private delegate int Win32WndProc(IntPtr hWnd, int Msg, int wParam, int
lParam);
public GenericWindow()
{
}
public void NotifyWindow(int windowHandle, int widgetHandle)
{
this.AssignHandle((IntPtr)windowHandle);
widgetH = widgetHandle;
oldWndProc = GetWindowLong((IntPtr)windowHandle, GWL_WNDPROC);
newWndProc = new Win32WndProc(MyWndProc);
SetWindowLong((IntPtr)windowHandle, GWL_WNDPROC, newWndProc);
//Every window has a procedure associated with it that receives all the
//messages that are sent to it. To subclass a window means to replace the
//procedure associated with the window by another user-defined procedure.
//The main use of subclassing windows is to customize how a window
appears
//or behaves. The handle of the procedure associated with the window can
//be obtained by calling the GetWindowLong function:
}
private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)
{
switch(Msg)
{
case WM_ERASEBKGND:
int calProc = CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
PaintExtras();
return calProc;
default:
return CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
}
}
public void PaintExtras()
{
int hdc = GetDC(widgetH);
if (hdc != 0)
{
int ret = ExtractIcon(this.Handle.ToInt32(),"C:\\somewhere\\x.ico",0);
int ret = DrawIcon (hdc, 1, 1, hIcon);
int ret = DestroyIcon (hIcon);
int ret = ReleaseDC(this.Handle.ToInt32(),hdc);
}
}
}
}
regards,
Stefan.
|
|
|
|
|
I've got a little problem... I wrote backup wizard that does the backup and if you selected the send via email option, it sends the files. Now on win98 it backup perfectly except for sending the email, it gives somekind of support error. Is the smtp only supported in 2000 and xp or is there any possible way that it can work in 98?
|
|
|
|
|
You might want to tell us what the EXACT error message is. Win98, out of the box, does have any support for a SMTP client. IIRC, the message objects only work on 2000 and above.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|