|
I think it should be easier to do the selecting via sql. If can't send mulitple sql-statements to the db you should try to get your data into a local Datatable object. Then you can query it locally via the Select method.
|
|
|
|
|
Well I have to do it the way I described it and it all works, except for the writing to XML thingie...
You can run through an ArrayList just like you run through a DataTable so it must be possible in a way. But that's just my problem, which way is the good way
|
|
|
|
|
Hello,
I'm working on a C# console program.
Now I've encountered the following problem:
I read data from a MS-SQL database and create Article objects with this data (own class).
An Article object exists out of the following members: custIDa, custIDb, docID, accountNr,
tCode, tTarif, VAT.
A customer can have multiple articles (so when custIDa is for example 1 it can have docID =
1 and docID = 2 (so 2 articles)).
I add every Article object to an ArrayList (and maybe I'll sort it).
What I want to accomplish is the following:
I want to run through the ArrayList and write the Article-data to XML like this:
<rootnode>
<customer ida="1" idb="UX200">
<accountnr value="453-2513-564">
<br />
<tarif value="5"><br />
<vat value="250"><br />
<br />
<br />
<customer ida="2" idb="BF500"><br />
<br />
<accountnr value="456-5465-546"><br />
<code><br />
<tarif value="2"><br />
<vat value="120"><br />
<br />
<br />
<accountnr value="456-5465-546"><br />
<code><br />
<tarif value="2"><br />
<vat value="568"><br />
<br />
<code><br />
<code><code><br />
<br />
I think I'll have to do this with a nested loop, 1 to check if custIDa is the same or has <br />
<br />
changed and one for the docID's.<br />
<br />
So custIDa can occur multiple times with everytime a changed docID (you could state that <br />
<br />
it's a combined primary key as in SQL).<br />
<br />
Anyone can help me out with this or has any ideas to help me out 'cause I'm really stuck <br />
<br />
here :(<br />
<br />
Thanks in advance!<br />
<br />
PS: Sorry for my English, I'm from Belgium ;)
|
|
|
|
|
I can't see your code. It's not showing up for me...
|
|
|
|
|
check (try 2) above
|
|
|
|
|
Dear friends,
I juat want to create windows custom user control which should have a property to set transparency.
How can i do this....Please provide me better solution...
amal
|
|
|
|
|
Try setting the color to System.Drawing.Colors.Transparent. If not supported, add a SetStyle(ControlStyles.SupportsTransparentBackColor, true); in your control's constructor.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Hi,
What is a signed assemblies ? Is it a component
that is encrypted and require a key to use it ?
So can I create a dll which require a key to use it in .NET environment ?
Many Thanks
|
|
|
|
|
Hi all,
I have a scheduler application, running as a windows service.
This application generates a Threading.Timer for each process with a callback called OnTimedEvent().
What is happening is that if two processes are scheduled at the same time, one of the processes may enter OnTimedEvent() multiple times (the current record is 10).
Threading.Timers were used as there is a bug with the System.Timers whereby if two events are scheduled at the same time one won't fire at all. This is a known issue and I was advised by Microsoft to use the Threading.Timers.
Does anybody know if it is possible to prevent this. I initially thought that multiple threads might be being created, but logging the thread id indicates that it is a single thread per scheduled item, and that single thread is entering the OnTimedEvent callback multiple times per event.
I tried a mutex at the start of the callback i.e.
public void OnTimedEvent(object objSource)
{
if(!m_mtxEvent.WaitOne(1, false))
{
Thread.Sleep(1500);
return;
}
lock(this)
{
// Do some processing here
}
}
Adding the Thread.Sleep(1500) line seemed to reduce the problem, but not eliminate it.
I knew I should have stuck to C++
|
|
|
|
|
How are you creating your timer? You should be specifying Timeout.Infinite for the constructor's period parameter if you want a one-shot timer.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks Mike.
I just found that out and I was about to post on here!
I only discovered it by accident though, as I realised I didn't need to specify a period as I have to re-compute the time to the next event anyway so removed some redundant code and set period to 0. This seems to fix the problem.
Regards
Simon Hart
|
|
|
|
|
I have a COM callable assembly written in C# which exposes 10 different functions to COM.
If I make changes to the internal functionality of the assembly I increase the revision number of the assembly version (i.e. 1.0.0.1 -> 1.0.0.2)
If I make changes to the COM definitions (i.e. changes to the type library) I increase the minor version of the assembly (i.e. 1.0.0.7 -> 1.1.0.7)
The problem I have is that regardless of any changes I make to the version is changes the tlb which means that the coders using the COM assembly (from Delphi) have to recompile.
Is there any way I can use versioning and not force the other coders to recompile (unless the COM interface has changed)
This problem probably has its roots firmly planted in my misunderstanding of version and type libraries, so I would appreciate any help.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
hi
i am developing application with which my application will send CGI requests to a web serverv and listen to responces
ho can i accomplish this using C# / how can i send sttp streams to web server using c#
Thanking you in anticipation it will be wondefull if any body can guides me
|
|
|
|
|
It's a long time I did this but I think you should have a look at the classes HTTPRequest/HTTPWebRequest/HTTPResponse/HTTPWebResponse.
Claudio
Claudio's Website
|
|
|
|
|
you can change the attribute of a file via the FileInfo object. This object has a member called Attributes and over this you can get or set the attributes of the file
FileInfo fi = new FileInfo(@"c:\1.txt");
fi.Attributes = FileAttributes.ReadOnly;
|
|
|
|
|
We're doing some bitmap manipulation and have come up against the issue of not being able to create a 2bpp bitmap. So we've implemented the following class:
<br />
public class BitmapSubsystem<br />
{<br />
public static readonly BitmapSubsystem Instance = new BitmapSubsystem();<br />
<br />
protected ColorPalette GetMonoColorPalette()<br />
{<br />
Bitmap bitmap = new Bitmap( 1, 1, PixelFormat.Format1bppIndexed );<br />
<br />
ColorPalette palette = bitmap.Palette;
<br />
palette.Entries[0] = Color.FromArgb( (int)0xFF, (int)0, (int)0,(int)0 );
palette.Entries[1] = Color.FromArgb( (int)0, (int)255, (int)255,(int)255 );
<br />
bitmap.Dispose();
<br />
return palette;
}<br />
<br />
public void ConvertTo2bppBitmap( Bitmap sourceBitmap, Stream output )<br />
{<br />
int Width = sourceBitmap.Width;<br />
int Height = sourceBitmap.Height;<br />
<br />
Bitmap bitmap = new Bitmap(Width, Height, PixelFormat.Format8bppIndexed);<br />
<br />
try<br />
{<br />
ColorPalette pal = GetMonoColorPalette();<br />
<br />
bitmap.Palette = pal;<br />
<br />
BitmapData bitmapData;<br />
Rectangle rect = new Rectangle(0, 0, Width, Height);<br />
<br />
bitmapData = bitmap.LockBits( rect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);<br />
<br />
IntPtr pixels = bitmapData.Scan0;<br />
<br />
unsafe<br />
{<br />
byte * pBits;<br />
if (bitmapData.Stride > 0)<br />
pBits = (byte *)pixels.ToPointer();<br />
else<br />
pBits = (byte *)pixels.ToPointer() + bitmapData.Stride*(Height-1);<br />
<br />
uint stride = (uint)Math.Abs(bitmapData.Stride);<br />
<br />
for ( uint row = 0; row < Height; ++row )<br />
{<br />
for ( uint col = 0; col < Width; ++col )<br />
{<br />
<br />
byte * p2bppPixel = pBits + row*stride + col;<br />
<br />
Color srcPixel = sourceBitmap.GetPixel((int)col, (int)row);<br />
<br />
double luminance = (srcPixel.R *0.299) + (srcPixel.G *0.587) + (srcPixel.B *0.114);<br />
<br />
if( luminance > 0 )<br />
*p2bppPixel = (byte)(1);<br />
else<br />
*p2bppPixel = (byte)(0);<br />
<br />
} <br />
} <br />
} <br />
<br />
bitmap.UnlockBits(bitmapData);<br />
<br />
bitmap.Save(output, ImageFormat.Gif);<br />
}<br />
catch<br />
{<br />
}<br />
<br />
bitmap.Dispose();<br />
} <br />
This uses some unsafe pointer manipulation to copy the bitmap across to a 2bpp image with transparency, and does the job nicely.
Question is, can this code be rewritten as managed code (using SetPixel/GetPixel)? I know it'll be a little slower, but we're only working on bitmaps that are 40px by 16px, so performance isn't too much of an issue. But SetPixel doesn't seem to allow me to set pixels on a 2bpp image - it seems to expect an ARGB value, rather than a pallette index....
If it can't be written as managed code, what are the implications of publishing unsafe code like the above? Is there a risk to my production webserver?
________________________
http://www.webreaper.net
|
|
|
|
|
Anyone?
________________________
http://www.webreaper.net
|
|
|
|
|
Hallo,
I'm a real beginner with C# and I have a silly problem with one DataTable combined with a DataGrid.
Short describing of surround:
I have one DataSet with three DataTables, each shown in DataGrids.
The DataSet is persistent (typed DataSet) as .xsd-file.
DataBase ist MSDE. All three DataTables are filled with the
DataAdapter.(DataSet, DataTable).Fill-Method.
If I execute the fill-Methode for one table twice or more, in my datagrid the records are added. To avoid this behaviour, I want to use the
DataSet.Tables["table"].Clear()-Method
before executing the Fill-Method. With two DataTables it works, but with the third, the DataGrid stays empty after the Fill-Method.
- in the debugger I can see that there are records in the DataTable
- when I click into the DataGrid, an error occurs that I try to translate (German version):
"DataBinding could not find line in list that can be used vor all bindings."
Help would be very appreciated.
Thanks
Vexta
|
|
|
|
|
Hi All
I have a form that holds multiple checkboxes. Currently the application, upon pressing a button, iterates through the controls on the form, determining which ones have been checked. It then takes appropriate action according to the selection. I use a foreach statement to iterate through the controls. Is there any way I can fix the order of iteration? The problem is I have another form that has the same checkboxes as the first but also adds a few. The method used to determine the action taken counts the controls as they are iterated through to learn the location of the checked control. However, in the second form the route through the controls using foreach is different making the count different. So any comparison of the count is invalid. I hope this makes sense.... The location of the checkbox in the count determines the action taken by the program. Multiple selections are possible.
Should I use the tag property to ensure or is there a way to for the foreach statement to follow the same path in both forms?
Kind Regards
Jamie
|
|
|
|
|
There is no way to alter the order in which the controls are iterated through. They come back in the order in which they were instantiated.
It sounds like your code needs to be modified so that the checkboxes update a central variable in the checkboxes own Click event handlers. The handler can update a count variable or modify a bit field as needed. Then your code doesn't have to iterate through or count anything, it was already done on-the-fly.
I'm sorry if this doesn't fit your requirements. I'm not sure why your couting anything and have even less of a clue why the order of the controls matters.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I was wondering how to convert a string like:
string myString = "1:00 PM,2:00 PM,8:00 PM,9:00 PM";
into a string array (or even better a DateTime array).
thanks,
Ron
|
|
|
|
|
string[] splitted = myString.Split(',');
To convert the result to a DateTime array you will have to loop through it and make it manually (Convert.ToDateTime on each element).
|
|
|
|
|
|
Hope this helps...
string myString = "1:00 PM,2:00 PM,8:00 PM,9:00 PM";
string[] myStringArray;
DateTime[] myDateArray;
// Split myString into an array
myStringArray = myString.Split(new char[] { ',' });
// Create an array to hold our times
myDateArray = new DateTime[myStringArray.Length];
// Step through our string array and create the times
for (int index = 0; index < myStringArray.Length; index ++)
myDateArray[index] = DateTime.Parse(myStringArray[index]);
|
|
|
|
|
I'm at the level in my programming experience where I understand algorithms and functions well, but I'm having a hard time conceptualizing classes and how they interact. Here's my problem:
I've got three classes: System, Room, and User. I need to dynamically instantiate multiple Rooms and multiple Users from the System class. Of course, accessing a particular Room or User from the System is easy enough, if I know the name, but I also need to access members of the System class from my Room classes, as well as members of the User classes from my Room classes.
So, my dilemma is twofold. First, how do I instantiate Room or Player classes dynamically; that is, how can I dynamically define the names of those classes as they are instantiated?
Second, since a class can only access the public methods and properties of classes instantiated within it, how in the world do I handle the communication between my classes, both queries from Room to System and queries from Room to User?
Or am I trying to bend unbreakable rules and need to go back to the drawing board? I appreciate any insights.
|
|
|
|