|
Hi Mark
thanks for the tip. WebRequest does have a timeout setting.
I have yet to test this, but is this the right approach?
HttpWebRequest hwReq = HttpWebRequest.Create("http://server/query");<br />
hwReq.Timeout = 120000;
WebResponse wRes = hwReq.GetResponse();<br />
XmlReader reader = XmlReader( wRes.GetResponseStream() );
Also, do you know whether the WebRequest.Timeout property deals with time to open the http connection, time between request and response, or time for response to complete? The response stream itself does have its own Timeout setting.
thanks again!
|
|
|
|
|
The timeout is inclusive. You can also use it asynchronously.
only two letters away from being an asset
|
|
|
|
|
if(!reader.IsDBNull(4))
{
c.SourceVideoClip=reader.GetString(4).Trim();
}
Can the above code, be refactored to use the tertiary operator?
/\ |_ E X E GG
|
|
|
|
|
Does this work:
c.SourceVideoClip= (!reader.IsDBNull(4)) ? c.SourceVideoClip = reader.GetString(4).Trim() : null;
/\ |_ E X E GG
|
|
|
|
|
No, when false no assignment should occur. Where did the null come from ?
The one possibility I see is:
c.SourceVideoClip= (!reader.IsDBNull(4)) ?
reader.GetString(4).Trim() : c.SourceVideoClip;
but even that is not absolutely correct; in several situations it could differ
from the original (when the condition is false):
when c is null;
when SourceVideoClip is a property without a getter;
when it is a property with side effects in its getter;
when it is a property that is not returning what you set it to (you should not do this, but you could...)
when it is volatile, i.e. other threads (or hardware) may cause it to change;
There may be a better attempt if something more was known about the c type !
|
|
|
|
|
Sure
SELECT param1, param2, param3, param4, ISNULL(SourceVideoClip, '')
FROM MyTable
c.SourceVideoClip=reader.GetString(4).Trim();
only two letters away from being an asset
|
|
|
|
|
Hello experts,
I'm trying to have a certain context menu popup when right clicking a ListView's headers, and another context menu popup when right clicking inside of the ListView.
Problem is I can't find a way to monitor right clicks on the headers.
The ColumnClick event only gets fired when left clicking, and the MouseUp, MouseDown, MouseClick, etc. events are only fired when the mouse is bellow the headers (inside of the ListView).
Any suggestions?
Thanks in advance,
Shy.
|
|
|
|
|
I've developed a simple workaround...
Here it is in case someone finds this post in the future...
The ContextMenuStrip property of the ListView is initially set to hold the context menu used when clicking the headers.
Assuming that the ListView is called "list", the context menu for the headers is called "ctxtHeaders", and the context menu for the body of the list is called "ctxtBody", here is the implementation:
private void list_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
list.ContextMenuStrip = ctxtBody;
}
private void ctxtBody_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
list.ContextMenuStrip = ctxtHeaders;
} The code is settings the list's context menu to the body's context menu every time it is about to be shown (i.e. when the right mouse botton is clicked).
Then, when the context menu is closed, the list's context menu is set to the headers context menu.
|
|
|
|
|
Hello world,
I'm working with vs 2005 using a typed dataset. I have a table, 'Trans', that has a relationship with 3 different parent tables ('Participants', 'Service Types', & 'Dependents'). In my actual database, Trans has a foreign key called 'serviceTypeID' which is the primary key in ServiceTypes. I just added a relationship with the other tables in visual studio. The problem lies in a column I created named 'service' in the Trans table. It's expression is Parent(FK_Transactions_ServiceTypes).service. This works fine when I run my program but as soon as I try to configure my TransactionsTableAdapter, I get this weird error 'Cannot find the parent relation 'FK_Transactions_ServiceTypes''. Mind you, I didn't rename the relation or even create it. It was done automatically and all the spelling is correct. Like I said, the expression works when I run my program. Anybody else run across this problem?
Lester
http://www.lestersconyers.com
|
|
|
|
|
Hi all
I am working with datagrid of 2005.I have 10 rows in it.It has three columns.
Id,Name,ParentId
Now my scenario is that if first records id is the parent id for all other 9 records, i need to select entire rows.for that i was using grid.select property but its not working,means its not getting selected
i am giving the partial code..can anyone give me what is gng wrong in this code
Advnaced thanks
for (int tmpCnt = 0; tmpCnt < AuthorisedTable.Rows.Count; tmpCnt++)
{
//if (dataGridAuthorised.IsSelected(tmpCnt) )//
if (AuthorisedTable.Rows[tmpCnt]["Type"].ToString()=="Meeting")
{
string tmpOtherID = (AuthorisedTable.Rows[tmpCnt]["EventId"].ToString());
for (int tmpRace = 0; tmpRace < AuthorisedTable.Rows.Count; tmpRace++)
{
if (AuthorisedTable.Rows[tmpRace]["OtherID"].ToString() == tmpOtherID)
{
this.dataGridAuthorised.Select(tmpRace);
}
}
}
}
Regards
DilipRam
|
|
|
|
|
Try to replace the
this.dataGridAuthorised.Select(tmpRace);
to
this.dataGridAuthorised.Rows[tmpRace].Selected=true;
And check the selection mode property.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Hi thanks for the reply, but i am not getting dataGridAuthorised.Rows property
Any idea
Regards
DilipRam
|
|
|
|
|
I have some Form - and i have some User Control on it.
I have also 6 button on the form and 4 button on the User Control.
In Form code i have some function that collect all the event from all the button ( The Form button and also from the User Control Button) .
My problem is that i need to know in run time witch button send me the event.
I cant use the "Tag" of the button because i using it for other target.
How to do it ?
How can i know if the button is Form relevant or relevant User control ???
Thanks for any help.
|
|
|
|
|
You can use the sender to find out which button was clicked
((Button)sender).Name<br />
|
|
|
|
|
I cant use this way because there are some button with same name on the Form and on the userControl.
I need some way to know who the owner of this button.
Is it the Form OR is it any of the userControls ....
|
|
|
|
|
Use the sender and the ((Control)sender).Parent property together to know which control is.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Hello,
I would use the 'as' operator for the casting.
Button actButton = sender as Button;
if(actButton!=null)
{
actButton.Name
if(actButton.Parent!=null)
{
if(actButton.Parent is YourUserControl_1)
{
}
else if(actButton.Parent is YourUserControl_2)
{
}
}
}
All the best,
Martin
|
|
|
|
|
|
All the best,
Martin
|
|
|
|
|
You can also check out this thread, which asked almost the same question.
http://www.codeproject.com/script/comments/forums.asp?forumid=387161&Page=3&userid=157870&mode=all&select=2094274&df=100&fr=231.5#xx2094274xx[^]
As others have already pointed out, casting the sender to a Button and then looking at it's properties (name, tag, etc.) to determine which button it is will be the best way to go.
The question that it seems no one asked is why do you need to route 10 buttons through the same event handler? Surely all 10 buttons don't do the same thing? If they actually do different things and you are trying to use 1 event handler to do some common things (like logging, for instance) you would probably be better off to use separate event handlers for each button and then have each event handler call a separate common method.
|
|
|
|
|
hi there,
i made a database on my D drive but i reinstalled the windows and sql server , so what i do now to load that database in my new sql server instance??
Becoming Programmer...
|
|
|
|
|
You need to "attach" the database. This is an operation available in Enterprise Studio (SQL 2000) and SQL Server Manager (SQL 2005). Have a quick search in your help to find out how.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Attach it in your SQL Server.
I Love SQL
|
|
|
|
|
Hello..
I'm having a device on the serial port sending a HEX string (34 46 FF 30) when I use programs like AccessPort I see the string like this "4Fÿ0"
But when I try to get the string in my aplication I get "4F?0" why???
I need to get the "FF/ÿ" HEX/CHAR in my aplication.
The aplication is going to read the 3char in the string and present this in a progressbar.
So I need to get the 3char a Desimal value from 0 to 255.
To do this I use the following code:
strig x = ComPort.ReadExisting();
Console.WriteLine(Convert.ToInt32(ConvertToHex(x.Substring(2, 1)), 16));
public string ConvertToHex(string asciiString)
{
string hex = "";
foreach (char c in asciiString)
{
int tmp = c;
hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
}
return hex;
}
Sorry for my english, hope you understand what I need..
Best regards Svein Jarle
|
|
|
|
|
With this code sample, I get the 4Fÿ0 back
using System;
using System.Collections.Generic;
using System.Text;
namespace TestBytes
{
class Program
{
static void Main(string[] args)
{
Encoding test = Encoding.Default;
string x = "\x34\x46\xFF\x30";
Console.WriteLine("{0}", x);
byte[] bytes = test.GetBytes(x);
for(int i = 0 ; i < bytes.Length ; i++)
{
Console.Write("{0:X2} ", bytes[i]);
}
Console.Write("\n");
Console.ReadLine();
}
}
}
Maybe you are on a different encoding.default ANSI code page on your PC ?
|
|
|
|