|
|
Please forgive me if this is a simple question -- I'm pretty new to C#.
Here's a quick code snippet that tries to take advantage of the ClearQuest API:
ClearQuestOleServer.SessionClass cqSession = new ClearQuestOleServer.SessionClass();
cqSession.UserLogon(login, password, dbName, (int)ClearQuestConstants.SessionType.AD_PRIVATE_SESSION, "");
object cqEntities = cqSession.GetEntityDefNames();
Now, when I run through this in the debugger and watch cqEntities, I can see that it's an array of strings (the "Type" field even claims that it's an "object {object[]}" type, with each item within it an "object {string}" type), but C# won't let me cast cqEntities as a string[], nor will it let me use cqEntities in a foreach (since it's not enumerable). What can I do to get at the stringy contents?
Thanks for any help you can offer!
|
|
|
|
|
I am not clear on your problems and I don't know the API:
object cqEntities = cqSession.GetEntityDefNames();
change to
String[] cqEntities = cqSession.GetEntityDefNames() as String[];
foreach (String str in cqEntities)
{
Console.Out.WriteLine(str);
}
Just let me know if it works
|
|
|
|
|
No, sadly, it doesn't; it merely sets up cqEntities as an array of nulls. Thanks, though!
|
|
|
|
|
Just a guess, but if you cast it (preferably with "as" and a null check) as an object[] first, you can then cast each element as a string in a foreach.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I'm having some luck with this one. Thanks! I should have thought of casting the function call as an array of objects myself!
modified on Thursday, December 17, 2009 10:29 AM
|
|
|
|
|
If you hover over the "GetEntityDefNames()" method in your VS editor, you should get a little popup that describes the type that the method returns. Match cqEntities with that type. Alternately the ClearQuest API docs should give you the proper return type. Even the VS class browser should be able to tell you what the type is. You'll want to avoid casting if you can, unless that's being forced on you by the ClearQuest API, in which case that's a heads up that it's not a very good API.
|
|
|
|
|
i got assignment to write a program(Server) for port listner the client program is written in java.
the client will send 69 byte that will be received by server and then processed.
i have written a simple TCP listner progam in c# but it always read upto 52 bytes and next 17 bytes are always 0
|
|
|
|
|
So, cut out the relevant bits, and post them here (within <pre>...</pre> blocks) - otherwise we can't tell what your problem might be...
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Do you have TCP no delay set ?
SetSocketOption(SocketOptionLevel.Tcp ,SocketOptionName.NoDelay, true);
It should not help in your case except if you made a mistake in your read operation.
TCP is a reliable stream delivery service that guarantees delivery of a data stream sent from one host to another without duplication or losing data but you may see your data cut in several packets. So, handling of re-assembly packets is necessary at the application level.
When the system is not loaded it's okay, but you will see when a system is at 99% of CPU usage it's not the same.
Hope it helps....
Just let me know
|
|
|
|
|
Is your recv or read function giving you back a total of 69 bytes? If so then the TCP part of the socket read is OK, and the "problem" lies on the server end in terms of what it's sending you. It's entirely possible that the server is in fact sending you 69 bytes, 52 of which are printable characters, and the remaining 17 padded out as 0's. A 0 is a perfectly valid byte value to send across a network.
|
|
|
|
|
Hi all,
I was trying and trying ...
in Visual c# .net I use a date which should besaved to the database:
DateTime TimeForTheDatabase = DateTime.Now;
... this is only an example ...
Now I will Insert "TimeForTheDatabase" to the Database:
SqlCommand dataCommand = new SqlCommand("Insert INTO table1 (Text,Datum) VALUES ("Info",TimeForTheDatabase)",dataConnection);
But I get an Error
Can somebody give me a sample how to insert my "TimeForTheDatabase" into my DB ?
Thanks
|
|
|
|
|
whats the error????? without error description how people can help you ?
Thanks,
Arindam D Tewary
|
|
|
|
|
the problem is format.
if u simply want to store datatime do in in db side
example
Insert INTO table1 (Text,Datum) VALUES ("Info",getdate())
|
|
|
|
|
OK, there are a few problems here. Do it this way:
SqlCommand dataCommand = new SqlCommand("INSERT INTO table1 (Text,Datum) VALUES (@TX,@DT)");
dataCommand.Parameters.AddWithValue("@TX", "Info");
dataCommand.Parameters.AddWithValue("@DT", TimeForTheDatabase);
That way you won't get the syntax error, and you can start to avoid SQL injection attacks later on.
[edit]I forgot the .Parameters bit. [/edit]
All those who believe in psycho kinesis, raise my hand.
modified on Thursday, December 17, 2009 10:07 AM
|
|
|
|
|
I am not sure SqlCommand has a AddWithValue method. You are supposed to add to the Parameters collection, not to the command object.
|
|
|
|
|
Corrected - thanks!
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
That is because the time format isn't converted to string.
Try this:
SqlCommand dataCommand = new SqlCommand(string.Format("Insert INTO table1 (Text,Datum) VALUES ('Info',{0})",TimeForTheDatabase),dataConnection);
|
|
|
|
|
No, never do that. Use parameters.
|
|
|
|
|
Not really recommended - firstly beacause it involves an unnecessary string conversion, and secondly because it is better practise to use parameters at all times. In this case there is no risk of an SQL injection attack, but all it would take is a small change to the logic...
See the XKCD cartoon "Bobby Tables"[^]
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Yes, for those reasons, plus performance in a loop:
If you concatenate SQL strings to insert a million such rows the server has to prepare a million SQL statements, but by using a parameterized statement the server prepares the statement once and uses the cached execution plan a million times (at least in theory).
|
|
|
|
|
Hi all i try make an injection into a Game .
some peaple draw menu in a lot of games mmorpg or fps like counterstrike.
i find this stuff kinda cool also for thing like customise windows application or change games interface let say turn ffxi interface into wow interface etc...
now i don't realy understand how peaple do that.
at first i though they inject an exe into the game process but look like its impossible.
so if peaple only inject a dll how they can draw menu? does the code of the dll draw it self a menu into game?
or maybe the dll load an exe into the games?
if someone can point me in the rigth direction from ground for built a simple menu into a games?
i realise i need c++ over c# not sure also.
|
|
|
|
|
evangile wrote: at first i though they inject an exe into the game process but look like its impossible.
Even forbidden, and you agreed not to when you first logged into Wow. As I remember, the agreement is shown after every update, usually on Wednesday.
Wow has a *damn cool* plugin system, can be extended over C#, and there's a coding4fun-article on building your own;
TweetCraft[^]
The way that a plugin is formed, varies from application to application though.
I are Troll
|
|
|
|
|
so to eddy you know blizard agreement worth nothing?
they actualy more than happy peaple developping private server so they have a cool demo version.
+ they have mass arangement with rmt.so they not realy care time peaple talk about wow they happy with dollard.
ffxi is way differente about that they have 0 tolerance but just for some helper application.
|
|
|
|
|
evangile wrote: so to eddy you know blizard agreement worth nothing?
They have the right to block you if you violate the agreement. I know that they will from personal experience
The coding4fun article using C# wouldn't be a violation though, the interfaces are defined just as the plugin-system expects it. Injecting things in another way could be seen as an attempt to hack the system (e.g., someone who tries to change the amount of money that's stored in memory; such a thing is impossible to do, but they *can* detect attempts)
Creating a mining-bot will get you in the same trouble, after some weeks. And why would you even want to, if there's a ready-to-run example in C# that you can customize to your own needs? They even explain how to make a Wow-like interface-window for your Tweets
I are Troll
|
|
|
|