|
Ok that was useful - not!
I've seen something like this when there is a problem in the credentials or the connection (to SQL SERVER at least). Try getting an copy of his MDB back to your site to test and stepping through the code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Put a TRY/CATCH in there and see if that gives more information. Could be something simple or more complex but it might be displayed in the CATCH EXCEPTION.
P/s - it is never good to have a topic of Very Urgent please . The guys don't like that as time and help is offered free of charge.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
|
Hi All,
I am trying to pass the values to managed code( C# ) to unmanaged code( C++ ). The following is the example code
[DllImport("Helper.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool Sample(long AccessibleContext,long vm);
<p> </p>
long ac = 10;
long id = 20;
Sample(ac,id);
<p> </p>
EXTERN_C __declspec(dllexport) BOOL Sample( long ac ,long id)
{
long sa;
sa = ac + id;
return true;
}
I am not always getting the value of the second parameter (ie "id") in C++ code, it comes as 0 but i am getting the first parameter value.
How can i resolve this problem?
Thanks in advance.
|
|
|
|
|
Hi. I think it's cos you are using longs in your C# code. longs in C# are 8 bytes instead of the 4 in C++. Try change them to ints in the C# side. Let me know if that works as I'm interested to find out.
|
|
|
|
|
Thanks Klempie..
After changing the long to int, it is working fine.
Thanks a lot.
|
|
|
|
|
No probs. I learnt something too.
|
|
|
|
|
In C++, we have pointer and address. How would we handle them when C++ code is converted to C#?
|
|
|
|
|
Hi There,
You do that by using the unsafe keyword, pointers are not safe type in c#, and as you know c# uses managed code which uses garbage collector, but in un-managed code the garbage collector cant interfear, pointers in c# requires writing unmanaged code, therefore you have to use the unsafe keyword.
Sincerely Samer Abu Rabie
Imagination is more important than knowledge !
|
|
|
|
|
I have a main thread with a mainform . I have a method that runs in a background thread that creates some new forms (of different type than mainform). The problem is that if i don't run the method in the mainthread then everything works fine. If i run this method in a background thread , and i make a mainthread.Invoke to create the form , then the form doesn't show up , also if i have checked that it's creation happens in the main thread.
How can i do?
How to create a form in a background thread ??
|
|
|
|
|
This works for me:
private void Form1_Load( object sender, EventArgs e )
{
new Thread( o => Invoke( ( Action ) ( () => new Form().Show() ) ) ).Start();
}
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Hi,
I have the following problem.
In my application 3 ports are open and are in listen mode. Continous message will recive to these port. I give one thread for each port. So when a message recive on one port will managed by the corresponding thread, at the same time another ports able to recive message.
My issue is, when a port recive a message it assign to a thread, soon when another message came to that same port it will assign to the running thread. Now two messages are executing by a single thread. It cause problem.
I want to wait the second message while running the thread. After finish the first thread the waiting message should assign to that thread.
Thankyou
YPKI
|
|
|
|
|
Hi again,
since you now have a thread reading a SerialPort you don't need the DataReceived event anymore, instead just call one of the Read methods and either collect or process the data, then read more.
This may or may not be complex depending on the protocol, the communication conventions, on your serial connection. The easiest one works like this:
- all information is structured in messages
- each message is encoded as text, and ends on a special character or short string (say an ASCII carriage return)
- the reading thread now can perform a ReadLine() which will collect and return data up to the first NewLine string (a CR)
As a result all your app is getting is complete messages.
All other schemes (binary data, no single message termination character, etc) may result in your app receiving fractions or multiples of messages, which forces you to add code to collect such data and split it in individual messages.
Anyway, once you have the code in place to accept one message, just process it before reading more data. One problem that might arise is your data coming in faster than your app can process; if so you need to either speed up your app, or slow down your data source, one way of doing that is by applying "dataflow control"
(see the HandShake property).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
i use thread.join for waiting the message in a particular port. So when number of message come at same time one by one will execute using single thread. At the same time other two port will free to recive message. so all the three port do work concurrently.
3 ports and 3 threads, each thread for each port. 3 DataReceived event for each port.
will this concept work well?
Thankyou
YPKI
|
|
|
|
|
ypki wrote:
will this concept work well?
I am afraid not. When you join the thread that got the data from a port, the thread is dead. Are you saying you start a thread for every single message you receive? that is very expensive. If you want all messages of all ports being serviced sequentially, set up a Queue, let your SerialPort threads receive messages (in a loop) and put them in the queue, and let another thread process all messages it can find in the queue.
That would be a typical producer-consumer configuration, with three producers and one consumer.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I've already done every article it's seem to be useful but can't fulfill my request.
I've just wanted to print all of my data from my datagrid. I have code it can run but this result is far from my thinking
here is code
private void button3_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
public void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics, new Rectangle(new Point(0, 0), this.Size));
this.InvokePaint(dataGridView1, myPaintArgs);
when i click on button3 it can print but show just only i can see from datagrid not all of datagrid
Thank in advance !!!!
|
|
|
|
|
Hi,
printing is a rather complex issue. The overall picture is your app has to do the pagination, it has to decide how much data fits on a page (PrintPage event will fire once for every page), and you should set PrintEventArgs.HasMorePages true for all but the last page. Furthermore, you have to keep track of the printing progress and implement the PrintPage handler such that it delivers the data belonging on the page currently being printed.
I don't have a simple example available, but there are lots of them on google. Maybe this one[^] can help you.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you very much for helping ^^
It's useful and I'm having a problem with datagridview right but I gonna deal with it.
Although it's so hurt ,I still choose love.
|
|
|
|
|
I have a C1FlexGrid component, to which I am binding a datasource, the following:
A collection of 'View' type objects (code below) which expose their properties for viewing by the grid.
The problem is the ordering of the columns of the C1FlexGrid component. I manually set them to be Number, Attach, Detach, but as soon as a DataSource is set, the column order for some reason changes to Attach, Number, Detach.
Is there a way to forcefully set the columns to appear in a certain order once a datasource has been set?
I was thinking perhaps there's an attribute (component model) to specify with each property but hours of googling and searching MS help has produced nothing!
Any help would be much appreciated!
g
<br />
class TrancheView<br />
{ <br />
private uint number;<br />
<br />
public TrancheView(BespokeTranche _tranche, uint _number)<br />
{<br />
this.tranche = _tranche;<br />
tranche.TrancheNumber = _number;<br />
this.number = _number;<br />
}<br />
<br />
public uint Number <br />
{<br />
get { return tranche.TrancheNumber; } <br />
}<br />
<br />
public decimal Attach<br />
{<br />
get { return tranche.Attach; }<br />
set {<br />
log.Info("setting Attach value");<br />
tranche.Attach = value;<br />
}<br />
}<br />
<br />
public decimal Detach<br />
{<br />
get { return tranche.Detach; }<br />
set<br />
{<br />
log.Info("setting Detach value");<br />
tranche.Detach = value;<br />
}<br />
} <br />
}<br />
<br />
|
|
|
|
|
Stuff like that is why I don't use data binding!
You might get more help if you ask this in the Component One Forums[^]
|
|
|
|
|
cheers yeah i dont have issue with databinding generally and think its quite a cool concept (saving time and ensuring robustness).
what i do have a problem with is when the order of columns are randomly shuffled for no reason!!!!!!
|
|
|
|
|
Hi all,
Does anyone know how to post messages to a message queue associated with the thread that created the specified window?
I am porting some cpde from VC++ to VC# and have stumbled acroos the VC++ function PostMessage, but i cant find a VC# equivalent or at the very least a way to accomplish what that function does.
Anyone got any pointers or ideas?
|
|
|
|
|
There are two Windows API functions PostMessage and SendMessage . In order to utilize them you will need to research a technique called P/Invoke.
Either Google for P/Invoke C#, or PostMessage C# or SendMessage C#
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Good People,
So, my software installs a file that is read/write while the application is running. During debug, it works fine - read/write no problem. So, I created an MSI (Windows Installer Project in Visual Studio 2008 Sp1) for the application. It installs fine.
However, now two problems have emerged:
1) It states that access to the path where the file is located has been denied (it's nested in Program Files).
2) I tried to uninstall it but it's telling me that the appropriate level of access to the registry (something about HKEY_CURRENT_USER roots, certificates, blah, blah...) is not present.
Any help you can provide would be great.
(What really irks me is that when I created the install project before, I never had this issue. I bet it's some setting I missed. Oh well.)
Thanks,
Blitz
|
|
|
|
|
Hi,
for 1) I am not surprised; you probably needed admin privileges to get your app installed (so all users can use it), however a regular user cannot write to Program Files and its descendents.
Furthermore, one could make the whole app folder (or even Program Files) read-only for added protection, so the user trying to write files there is no good.
I suggest you use one of the preferred file locations using the Environment.GetFolderPath() method, probably with the SpecialFolder.ApplicationData or .CommonApplicationData parameter. You can creaye subfolders and files in there as much as you need to or want to.
Mind you, the actual path returned by GetFolderPath will depend on the specific Windows version, and some admin choices made while installing Windows; however the method takes care of all that.
for 2) I have no idea.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|