|
Jason, what exactly are you having trouble with? The DVTSID1 component? Declaring the strings? Declaring the function? (by the way, that looks like an incomplete function, as there's a "End Sub" but there's no beginning of the function, e.g. the declaration)
|
|
|
|
|
You are right I didn't get everything when I copied the code. I am doing other functions after I receive the data that are not related so I just copied the code I was having questions about. The main question I have is the Datalink function, it does not seem to exist in C#, at least to my understanding. As I stated I am not familiar with C# as of yet. So I want to listen to port 5001 using the IP address, what would be the best way to accomplish this task?
Thank you
Jason
|
|
|
|
|
Hey Jason,
I've never heard of DataLink until now. A quick Google search reveals this article[^], which mentions that it is a COM object. Since it is a COM object, you can use it in C# (or any other .NET language). See the article for an example on how to do this in VB.NET, but it should be essentially the same steps in C#.
Let me know if you have any more questions.
|
|
|
|
|
I need to convert any integer value greate than 127 to binary value using this example:
Represent the value in binary
(e.g 137 => 1000 1001)
2) Break in up in groups of 7 bits from the lowest significant bit.
(1 | 000 1001)
3) Take the lowest 7 bits and that gives you the lowest byte (0000 1001)
4) For the next group of 7 bits (in the example, this is 000 0001), set the MSB to 1 (which gives 1000 0001 in our example).
Thus 137 becomes:
1000 0001 0000 1001
can anyone help me do this code using | & operators shif to left operators
Thanks
|
|
|
|
|
Hi,
I suggest you use unsigned integers for binary, octal, hexadecimal conversion.
It is much easier, all 8/15/32/64 bits then behave in the same manner.
Fara76 wrote: Break in up in groups of 7 bits
That is definitely wrong, today's computers have 8 bits in a byte, and one or
more bytes in their data path components (registers, ALUs, data bus, ...); there
is absolutely no reason whatsoever to work in groups of 7 bits.
|
|
|
|
|
static void Main(string[] args)
{
int number = 0;
try
{
if (args.Length == 0)
{
throw new Exception("Number not specified");
}
if (!int.TryParse(args[0], out number))
{
throw new Exception("Could not convert value to integer");
}
const int power = 7;
int tmpNumber = number;
int i = 1;
int maxValue = (int)Math.Pow((double)2, (double)power * i);
while (number >= maxValue)
{
tmpNumber |= maxValue << 6;
maxValue = (int)Math.Pow((double)2, (double)power * ++i);
}
Console.WriteLine(tmpNumber.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Exception occured");
while (ex != null)
{
Console.WriteLine(String.Format("Message: {0}", ex.Message));
Console.WriteLine(String.Format("Stack trace: {0}", ex.StackTrace));
ex = ex.InnerException;
}
}
finally
{
Console.ReadLine();
}
}
|
|
|
|
|
Thanks a lot, but would you explain the code please? i get 8329 for the value of 137? i don't understand why? and i also can you please explain how to change the final answer to bytes so i will have 100000001 00001001 in bytes ?
Thanks
|
|
|
|
|
It looks like you're trying to implement a multi-precision integer. But outside of the MIDI specification I don't know where an MPI of this type would still be in use today, so it sounds almost like a homework assignment.
What do you have so far? Maybe we could take a look at that and figure out what's going wrong in your code.
|
|
|
|
|
I finally fixed the code, it is working now! thanks anyway
|
|
|
|
|
I am trying to implement state verification as part of our automated testing framework. I want to use aspects to run a pre check and post check of any particular method call and only have an attribute indicating that that would be a verifiable method. This would be transparent to both the called and client code, performance is not an issue.
There are two articles i have fond on the code project that touch on aspects in C#:
http://www.codeproject.com/cs/design/aopsimplestscenario.asp?msg=2160427&mode=all&userid=3765364#xx2160427xx
http://www.codeproject.com/csharp/aspectintercept.asp?msg=2145384&mode=all&userid=3765364#xx2145384xx
Both use ContextBoundObject in their implementations. It seems that both solutions suffer from the same problem. Method injection does not work when a method is called from inside its own class. Something like this.
/***Will properly call pre and post methods*****/
MyClass myClass = new MyClass();
myClass.CallMethod();
/***Will not call pre and post methods*****/
this.CallMethod()
Has anyone else run into this problem? Am i going down the wrong path? Is there a better solution to the problem?
|
|
|
|
|
Not sure if it's what you are looking for, but have you looked at the Policy Injection Block in the latest Enterprise Library release?
http://www.codeplex.com/entlib[^]
only two letters away from being an asset
|
|
|
|
|
Hi folks-- first post
I'm encountering timeouts when opening URLs to a long-running webpage. It's actually a web service of sorts; the url returns an XML-encoded query result. The problem is that the result is pretty big and can take more than a minute to run. The C# program fails with an exception related to the timeout.
XmlReader reader = XmlReader.Create("http://theserver/thequery?param=1");
The problem is, I can't figure out how to adjust the timeout. That setting is in one of the hidden classes that XMLReader wraps (possibly System.IO.Stream.ReadTimeout or .CanTimeout), but I there doesn't seem to be a way to get to it to change or turn off the timeout.
Help??
|
|
|
|
|
May you should change tactics then. Use a WebRequest and create the XmlReader after the results have been returned.
only two letters away from being an asset
|
|
|
|
|
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
|
|
|
|