|
i fill 1 data table from database . i have 1 datagrid on the form that i fill it manually. can i add one of the columns of the data table to my datagrid?
thank you
|
|
|
|
|
Yes you can, add a new column to the datasource (DataTable??) which you are creating manually and fill data in that newly added column from datatable filled from database.
Saqib
|
|
|
|
|
I created a global hotkey (Alt + F) using the RegisterHotKey API and then in WndProc caught the WM_HOTKEY message and then started a keyboard hook which blocks all keys typed from reaching other applications. (The point of this was so I could press alt+f type in a command and press enter to execute whatever app or website that's associated with the command.) The hook is started using the SetWindowsHookEx API with a delagte pointing to a procedure that catches WM_KEYDOWN and WM_KEYUP message. (Based on the code found at http://www.codeproject.com/csharp/globalhook.asp[^])
My problem is that after stoping the hook the 'alt' key is still in it's keydown state (I'm guessing that the hook ate the keyup message instead of sending it back) so pressing keys on the keyboard will access the menu or whatever other hotkeys there are. I've tried sending a WM_KEYUP message (using SendMessage API) for the alt key after the hook was stopped, but it didn't work. I wasn't sure of what window handle to send it to for a hotkey or if it even matters (I used the main form of which the hotkey was registed with).
Thanks
Blake
|
|
|
|
|
Hi,
I am writing a multihread app in C# 2003. There is unmanaged dll in it.
When GC activates after memory reaches the some level of fullness,an exception is thrown. It is access violation exception from mscorwks.dll and application crashes.
If someone has an idea about it, it would be really helpful.
Best regards
asbasir
|
|
|
|
|
Hi,
I would like to find out how to append a bitmap to an existing bitmap in .net 2.0. I am programming in C++/CLI but C# code will also be fine.
What I am trying to accomplish is a 'Render to Disk' feature, where I can create a very large bitmap image on disk by appending a 'strip' at a time to the bottom of the image; thus growing the bitmap on the disk.
I have tried using the SaveAdd method, but have been unsucessful. Is this the right approach or am I barking up the wrong tree? Here is some code that I tried:
EncoderParameters^ params = gcnew EncoderParameters(1);
params->Param[0] = gcnew EncoderParameter(Encoder::ColorDepth, (short)32);
saveBitmap->Save(saveBitmapDialog->FileName, codec, params);
saveBitmap->SaveAdd(params);
The Save method works fine and results in a bitmap on disk, but SaveAdd fails. Any ideas would be greatly appreciated, there does not seem to be much info about this on the net.
Thanks!
zenzero
|
|
|
|
|
The SaveAdd method is used to add a frame to a multi-frame image, not to write a part of a larger image.
There is nothing in the framework to support partial writing of a large image. You have to do it by hand.
Look into the bitmap file format. There is no compression so the file format is fairly simple.
You have to specify how large the final image will be when you write the file header to the file.
One thing that might cause you some problem is that bitmap images are stored upside down...
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for that Guffa. I know not to waste any more time with SaveAdd !
I tried the old fashioned way before but couldn't get it to work, but that was probably because I wrote the wrong size to the file header. I would just see a single strip visible yet the file size would indicate that all the data was there.
Thanks for the illumination,
zenzero
|
|
|
|
|
Hello,
I want to use multiple queries (so, in the while-loop of a reader, i want to use another query + reader).
The folowwing code will give an example:
<br />
SqlCommand myCommand = new SqlCommand("SELECT date, customerid FROM orders ORDER BY date ASC", connect);<br />
SqlDataReader myReader = myCommand.ExecuteReader();<br />
while (myReader.Read())<br />
{<br />
SqlCommand myCommand2 = new SqlCommand("SELECT customer FROM customers WHERE id = " + myReader["customerid"] + " ORDER BY date ASC", connect);<br />
SqlDataReader myReader2 = myCommand2.ExecuteReader();<br />
while (myReader2.Read())<br />
listBestellingen.Items.Add(myReader["date"] + " " + myReader2["customer"]);<br />
}<br />
myReader.Close();<br />
But he sais i allready have a reader open (which is the truth), and that i have to close it, but that's a no can do)..
Can somebody help me?
Thanks!
-- modified at 16:20 Thursday 25th May, 2006
|
|
|
|
|
A datareader keeps the connection open exclusively for the duration of its read operation.
There are 2 ways to rectify this:
1. use another connection for the second datareader
2. Read the contents of first datareader into an arraylist, close the datareader and then use the same connection for the second datareader (recommended).
With Regards
Shane Sukul
BSc Mcsd.Net Mcsd Mcad
.Net Architect/Developer
Ashlen Consulting Services P/L
|
|
|
|
|
Or a third option to produce a better SQL command that only requires one reader.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
You can only have one active reader per connection. You must open a new connection to run two readers simultaneously on the same database. You also don't close your second reader which means it won't get closed until the garbage collector cleans it up - and that may not be for a long time.
However, you can do all this with one SQL command:
SELECT orders.[date], cusomter.customer
FROM orders
INNER JOIN customer ON orders.customerid = customer.id
ORDER BY [date] ASC
So your code would look like this:
SqlCommand = myCommand = new SqlCommand("SELECT orders.[date], cusomter.customer"+
"FROM orders INNER JOIN customer ON orders.customerid = customer.id ORDER BY [date] ASC";
SqlDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
listBestellingen.Items.Add(myReader["date"] + " " + myReader["customer"]);
}
myReader.Close();
Does this help?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
|
SQL Server 2005 supports having multiple readers open at the same time. (A feature called MARS).
You need to add MultipleActiveResultSets=True to the connectionstring to make this work for your connection.
string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;IntegratedSecurity=SSPI;MultipleActiveResultSets=True";
|
|
|
|
|
Hello,
I'm using Visual Studio 2003. I have a simple windows form that I am working with in the Form Designer in Visual Studio. Whenever I change the size of the form in the Designer, then click save, rebuild and run, the changes do not take effect. The form still has the old size. In the InitializeComponent() method, the size of the form is changed. Does anyone know why this may be happening? Thanks in advance.
|
|
|
|
|
Try to "Clean solution".
Best regards, Alexey.
|
|
|
|
|
I'm developing an IExtenderProvider that will be located in a dll. From the code in the IExtenderProvider I want to find out the name of the control that is extended including it's namespace path, ie something like "WindowsApplication1.Form1.button1". How can I achive this?
Thanks in advance
Christian
|
|
|
|
|
In the class that implements IExtenderProvider write a routine to get the name and inside put something like:
string name = this.GetType().FullName
It's that simple! Might I suggest if you're writing lots of these extenders to create a base class which has this method already implemented.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Thanks a bunch. I'm going to try this right away!
Right now I'm only writing one such extender, but otherwise it would be a good idea.
BR
Christian
|
|
|
|
|
Well. It didn't quite cut it. I'm wondering if it's because of the fact that the extender is in a dll that the windows application is referencing?
-- modified at 16:53 Thursday 25th May, 2006
When I use it, it returns "System.Windows.Forms.Button".
|
|
|
|
|
The following code (just a simple example):
using System;
using System.Windows.Forms;
namespace PiLogic.Windows.Forms
{
public class Test : Button
{
public string GetName()
{
return this.GetType().FullName;
}
public static void Main(string[] args)
{
Test test = new Test();
Console.WriteLine(test.GetName());
}
}
}
Displays the following text when run:
PiLogic.Windows.Forms.Test
So I don't know why you get System.Windows.Forms.Button, you sure your using this and not base ?
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
The code is in an Extender. The extender gets a reference to the control as an object. The IExtenderProvider class is in a different assembly than the Button object. The dll does not reference the project with the form and button, as that would create circular references. I think that the IExtenderProvider evaluates the type to one that it's aware of.
This is not my actual code, but I think you get the idea.
bool IExtenderProvider.CanExtend(object o)
{
Console.WriteLine(o.GetType().FullName);
}
The button object is actually a System.Windows.Forms.Button type. Therefor I add the name of the Form that is parent of the IExtenderProvider to the name of the button. This will give me Form1.button1, but I also need the namespace that Form1 belongs to. If I do GetType().FullName on the form I get System.Windows.Forms.Form, but the actual type of the form would be WindowsApplication1.Form1.
Do I make sense?
/Christian
|
|
|
|
|
I get what you're trying to do now. The only way I can think of at the moment is you're going to have to create a pile of recursive functions to walk up through the button's parent hierarchy to extract the name. GetType () will just extract the base type of the button.
You can use the Name property of the control, and then iterate backwards to it's parent form and the parent form's namespace etc. But I think that this is a bad way to do it. As I said, I can't think of another way at the moment, I'll keep trying but might I suggest trying to find another way around this. Can you store the actual references rather than the names? Then (I'm guessing now ) if you need to compare the two objects you can use == to do it.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Thanks for your input. I have already prepared a workaround, as I don't want this issue to tie me up any longer. I'm using the form name and the control name only.
I can understand why GetType().Name returns System.Windows.Forms.Button for the button, because my button is only an instance of that type. The form on the other hand is an instance of a custom made class that inherits from System.Windows.Forms.Form. Because of this, the function should return the name of my class that the object is instanciating.
Again, thank you for your effort.
/Christian
|
|
|
|
|
Hi Guys,
I cant find any section for Biztalk server in the Code Project.
Is it not relevant here?
Or should we have it?
I strongly believe that we should have a section for Biztalk so that we can share Biztalk related project samples and information.
Thanks
Firoz Ozma
..:: firozOzman ::..
http://spaces.msn.com/members/firozozman/
|
|
|
|
|
i m very bad in c# programming
can anyone tell me good websites or books to learn c# programming.
plzzzzzzzzz its very urgenttt
|
|
|
|