|
hi all,
I am developing a windows application using C#. i am using gridview to display the records of a table. i need to display new records that comes latest at the top of a table. i am using a timer for every minute to check the table for records.
i need to display a alert saying that a new record has come.
i wrote the following code,
string display = "";
display = "select count(*) as count,fname,emp_id from emp_new where status=0 and " +
"hire_date='" + DateTime.Today + "' group by emp_id,fname order by emp_id desc";
sqlcomm = new SqlCommand(display, conn);
sread = sqlcomm.ExecuteReader();
while (sread.Read())
{
panel1.Visible = false;
count = (int)sread["count"];
employee = sread["fname"].ToString();
display_count();
}
sread.Dispose();
sqlcomm.Dispose();
and in the display_count method, i am displaying the message in a label control.
but it displays only the last new message. i need to display each record in a gap interval of 5 seconds
how to do this?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
There is probably an ajax way of doing this, but I am not that familar with ajax. I would use a meta tag to auto update the page. Here is the syntax:
<meta http-equiv="Refresh" content="n;url">
n is the number of seconds to wait before loading the specified URL.
url is an absolute URL to be loaded.
This will cause your page to auto post back in which case you can run your query and update the gridview.
Hope that helps.
Ben
|
|
|
|
|
Thanks for the reply. but if you notice, i am using a windows application and not a web application..
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
Sorry about that. I guess I wasn't quite awake when I read your post. I saw gridview and was thinking web.
Ben
|
|
|
|
|
Hello,
So you are getting the datas in the right time intervall, but only the last one will be updated?
I think you have to call
Application.DoEvents();
after
display_count();
If this is the method were you set the text of the label.
All the best,
Martin
|
|
|
|
|
hi martin,
yes,i am getting the datas in the timer. i did call the application.doevents() as you said.
but still i am getting only the last new message.
in the method display_count, i am displaying the text in the label control.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
Hello,
Hmm,
I'm not very familiar with SQLCommands and it's possibility of a threading problem in combination with GUI interaction, but maybe the method which setts the label text, needs to be invoked. (Please correct me if this is total rubbish!)Check 'InvokeRequired'.
All the best,
Martin
|
|
|
|
|
I think this would do it.
display_count();
Application.DoEvents();
System.Threading.Thread.Sleep(5000);
}
Hope that helps.
Ben
|
|
|
|
|
Hi,
I've a COM-object written in C++ (VS 6), that is used in my C# (.NET 2.0) application. Everything works fine when my program runs on my computer (where it is build). But as soon as I copy this program to another computer, register that COM using regsvr32.exe MyCOM.dll , when calling that com I get Exception - Attemp to read or write protected memory. and things stop to work...
do you have any idea what could be wrong?
thanx
|
|
|
|
|
hi there,
i wanna compare buttons background image something like this :
if (abcBtn.BackgroundImage != Properties.Resources.abc_un)
or like this
if (xyz.BackgroundImage == global::mypro.Properties.Resources.xyz_cur)
both code arent working properly but their working are different
in first Code C# is entering in if statemen where abcBtn background image is different (eg. def image)
in second code C# isnt entering in if statement where xyz background is same as written "xyz_cur"
Becoming Programmer...
|
|
|
|
|
Usually when I have compared images, I put them into bitmaps and compare the pixels. I am sure there are better ways of doing it. It can be slow, sometime I only compare every other pixel to speed it up.
Hope that helps.
Ben
|
|
|
|
|
Hi All,
I am trying to develop POP3 application in C# and have successfully managed to create a connection with POP3 server on port 110. here is the sample code ihv written for this:
Server = new TcpClient(POPServ.Text, 110);
NetStrm = Server.GetStream();
RdStrm = new StreamReader(NetStrm);
Inorder to retrieve messages from a service such as Gmail, i need to enable the SSL. I don't want to use any pre-built component. Is it possible to use SSL functionality without using any 3rd party components?? if so, could anyone please assist me on this...
Meanwhile, I have tried to connect to gmail server using the port 995. Its connected successfully, but my application getting hanged at particular line of code: (bolded below)
Server = new TcpClient(POPServ.Text, 995);
NetStrm = Server.GetStream();
RdStrm = new StreamReader(NetStrm);
plz help me on this issue...
Thanks in Advance.
|
|
|
|
|
Hi
It depends on the .net version you use. if you're using .net 1.1 you will have to use a 3rd party library (the mentalis.org security lib is pretty good and free)
in .net 2.0 there are security classes in the System.Net.Security - Namespace
greets m@u
|
|
|
|
|
Hi, thanks for replying..
I am using .net 2.0 & yes i got SSLProtocols. but didn't find any "usessl" or "enablessl" method...
if you are aware of anything, plz help me out...
Thanks.
|
|
|
|
|
Hello,
As you now i wont be able to have a messagebox running as a server side script.
Hence icant use messagebox.show method in my code in C sharp.
hence i would like to incorporate a client side script or a java script.
Can any one assist me with the code?
Thanks for your time
|
|
|
|
|
kibromg wrote: hence i would like to incorporate a client side script or a java script.
Can any one assist me with the code?
window.alert ?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
kibromg wrote: as a server side script.
Hence icant use messagebox.show method in my code in C sharp
You can create a class with Show() method, and write the script what Colin suggested to response.
|
|
|
|
|
i didnt see colins message? Could you please give me a tip of the script please as i havenot used java script??
Thanks
|
|
|
|
|
kibromg wrote: i didnt see colins message?
Click Here[^]
kibromg wrote: Could you please give me a tip of the script please as i havenot used java script??
The function used to show messages in javascript is alert(). What I mean, if you want to use this in several places as you do in MessageBox.Show, it's better to wrap it inside a class. That could be something like this
class CMessageBox
{
public static void Show(Page _page,string Message)
{
_page.Response.Write("<script language='javascript'>alert('" + Message + "')</script");
}
}
In you page where ever needed call it like CMessageBox.Show(this,"YourMessage");
|
|
|
|
|
function Show(strMessage)
{
alert(strMessage);
}
Regards,
Valan
|
|
|
|
|
Thank you all for your cooperation.
I will try it now.
Thanks
|
|
|
|
|
Hi all, I have an usercontrol with a TableLyoutPanel. Inheriting controls should put a panel in each row of the tablelayout, but I've just discovered that TableLayoutPanels cannot be edited in inherited classes from the visual editor.
I cannot ask the implementators of the base class to design the many panels by code, how can I add them to the TableLayouPanel still making them able to design theyr controls with the editor?
Thank you!
|
|
|
|
|
I have suffered the same problem. And after reading this I decided to search and alternative...
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
For some reason I'm unable to open the link... Anyway, if your're pointing me toward a third party control, I wont most probably be allowed to use it (I could always ask though...).
One possible solution, not really elegant, would be adding a method GetTablePanel() that returns the tablepanel, which would be added by the inheriting classes instead than by the parent.
I don't really like that solution, because it would make harder for the parent class to take care of some details withouth having the children to worry about them. I should be able to find a way to accomplish this anyway.
|
|
|
|
|