|
hello all,
how can i access data from database server which is on web in my
destop window application in crystal report
there is remote access alowed from the server
but when i use it with crystal report 10 logon failed error
it work fine with web app but what to do with desktop
plz help me
|
|
|
|
|
Hi, I’m trying to get some objects to move around in a 2d array of lists, but the program keeps exiting with ‘System.InvalidOperationException’ and “Additional information: Collection was modified; enumeration operation may not execute.”
I’m pretty sure that this is the part of the code causing all the problems-
public void cycleThroughList()<br />
{<br />
for (int x = 0; x < GridDimention; x++)<br />
{<br />
for (int y = 0; y < GridDimention; y++)<br />
{<br />
foreach (Microbe i in theWorld[x, y])<br />
{<br />
i.Talk();<br />
Update_Position(i);<br />
<br />
}<br />
}<br />
}<br />
}<br />
<br />
public void Update_Position (Microbe m)<br />
{<br />
if (m.sX != 0 & m.sY != 0)<br />
{ <br />
theWorld[m.positionX, m.positionY].Remove (m);<br />
theWorld[m.positionX + m.sX, m.positionY + m.sY].Add (m); <br />
}<br />
<br />
m.Talk();<br />
}
Where ‘Talk’ is a method that writes to the console the coordinates of the Microbe object, and the ‘int sX’ and ‘int sY’ are the modifications to the objects location on the array.
Do you guys have any idea how to fix this?
I really appreciate any advice you can give me!
|
|
|
|
|
F Green wrote: foreach (Microbe i in theWorld[x, y])
{
i.Talk();
Update_Position(i);
}
}
The error means what it says. You cannot modify a collection while you're using it in a foreach, you need instead to write standard for loops.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I got an Image_click that makes an image become another image.
I want it to increment each time I click on it.
I got the increment right, the image changer right.
But the image_click just won't work twice.
Is there any function or method I can use?
|
|
|
|
|
Fenix2 wrote: But the image_click just won't work twice.
What on earth do you mean ? what happens ? Perhaps you need to post code ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Well... Code won't help.
The clicking procedure works fine.
And the declaration of the image is fine too...
Still wanna see?
private: System::Void TS11_MCli(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
Tsn11 = Tsn11 + 1 ;
if (Tsn11 = 0) { this->TS11->Image = Image::FromFile("C:/GamePics/NOTILE.png");}
else {
if (Tsn11 = 1){ this->TS11->Image = Image::FromFile("C:/GamePics/GREEN.png");}
else {
if (Tsn11 = 2){ this->TS11->Image = Image::FromFile("C:/GamePics/GRTRE.png");}
else {
if (Tsn11 = 3){ this->TS11->Image = Image::FromFile("C:/GamePics/ROAD.png");}
else {
if (Tsn11 = 4){ this->TS11->Image = Image::FromFile("C:/GamePics/WALL.png");}
};
};
};
};
};
};
};
This was the clicking function.
When I click first time, the image switches to GREEN.png
When I click second time, the image stays as GREEN.png
|
|
|
|
|
A new dialect? My C# compiler refuses all of it.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Maybe is it because you don't have that image in your Form...!!!
|
|
|
|
|
Someone in C++ C MFC thinks it's C++ CLI...
Would it?
|
|
|
|
|
Yeah Sounds like it is...
Sorry for that
|
|
|
|
|
Hi Everyone,
I am using button's obj in datagridview and set the flag as true to show the text value of the button (Name of the Button). If user clicks on the button, its changes the button’s name based upon the criteria. I am doing very simple code here.
I set button’s name as “buttonColumn.UseColumnTextForButtonValue = true;”
Now If I want to change the value with following settings. It did not work it out.
dataGridView1[e.ColumnIndex, e.RowIndex].Value = "America"; It is still taking "Name"
Can you please help me on this?
private void CreateButtonColumn()
{
// Initialize the button column.
DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn();
// Add the button column to the control.
buttonColumn = new DataGridViewButtonColumn();
buttonColumn.Name = "Name";
buttonColumn.Text = "Name";
buttonColumn.Width = 110;
buttonColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Insert(0, buttonColumn);
dataGridView1.Rows.Add(2);
dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
}
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToInt32(e.ColumnIndex) == 0)
{
dataGridView1[e.ColumnIndex, e.RowIndex].Value = "America";
}
}
Thanks.
|
|
|
|
|
I've not tried this but from your code, an obvious thing to try would seem to be
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToInt32(e.ColumnIndex) == 0)
{
((DataGridViewButtonColumn)dataGridView1.Columns[e.ColumnIndex]).UseColumnTextForButtonValue = false;
dataGridView1[e.ColumnIndex, e.RowIndex].Value = "America";
}
}
Hope this helps.
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.”
|
|
|
|
|
Thanks. This is very good one. Just to mention one thing here. Its changes all the rows with new value "America".
I want to updates the same cell where was cliked.
Once Again
Thanks
|
|
|
|
|
Ah!
Well, it was worth a try.
I have searched through my own code for examples of using a DataGridviewButtonColumn and all of the examples I found used the button click to load a data entry form to get the required data. on return from the data entry form they used the following syntax to set the value(s) entered:
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToInt32(e.ColumnIndex) == 0)
{
dataGridView1.Rows[e.RowIndex].Cells["Name"].Value = "America";
}
}
which is setting the value of the appropriate Cell in the underlying DataGridViewRow .
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.”
|
|
|
|
|
I'm passing a delegate to unmanaged code, and the unmanaged code calls back into managed code.
I'm getting a mysterious "buffer overrun" error, and I wonder if the problem might be that I must pin the delegate.
But C# doesn't have the "pin_ptr" keyword. How would I do that?
EDIT: The pinned delegate must exist for the lifetime of the application, so the "fixed" keyword, which operates only on a small scope, would not be feasible.
FIX -- The buffer overrun error was caused by a mismatch of calling conventions. I simply applied the following attribute to my delegate, and that fixed the problem:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
modified on Tuesday, October 6, 2009 5:30 PM
|
|
|
|
|
In my experience, there is no need to pin a delegate, just make sure it stays alive for as long as any call backs are expected. I believe the internal marshaling takes care of tracking the managed function pointer (if it is moved), but if it is garbage collected you will get errors if the unamanaged code attempts to call it.
|
|
|
|
|
Hi
Does anyone know how to dispose backgroundworker completely and release all the system resources associated with it?
I called cancelAsync and then backgroundworker.Dispose(), even then it shows backgroundworker.IsBusy = true.
Please help
Vsaratkar
|
|
|
|
|
Just because it shows IsBusy = true, why do you think it's using resources ? What resources do you expect it could be using ( answer, close to none, unless it uses something explicit, like Bitmaps, which you should have cleaned up explicitly yourself )
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Calling CancelAsync just sets CancellationPending - it's up to you to check this property at apropriate places in your DoWork handler, and if it's set - set e.Cancel and return from the handler. Then, and only then will RunWorkerCompleted be called and the background thread terminated.
[Edit] Here's the source[^] that shows BackgroundWorker is implemented [/Edit]
|
|
|
|
|
Thanks Christian and DaveyM69 for your prompt replies.
I will explain my application in brief.
Actaully we are uploading 3 different types of data to the web Server using Webrequest and Webresponse classes.
First type of data are values which uploads at once, second is very small binary file around 1kb and third type of data is photo which takes around 50 seconds for one photo to upload. Our application is taking multiple photos.
I want to show 3 individual progress bars for 3 uploads and one main bar for all 3 types of data upload.
I have created a class "UPloader" with events to manage the progress bars by passing variables to UI and instantiate that class in UI window.
I am using background worker in "UPloader" class to make 4 requests and get responses because I want to give user the facility to cancel the upload. Backgroundworker is a public variable and in UI on cancel button click, I am calling Uploader.BackgroundWorker.cancelAsync.
I am using compact database to hold the data. When I say "cancel", it cancels the upload, but when I try to upload the data without logging out the application, then I get NullReference exception. But if I log in to the application, I could able to upload the data.
I was wondering is this a good approach, because I want to give user "cancel" functionality.
I am not sure if one backgroundworker can manage 3 different Webrequests and webresponses.
If you know any better way to implement this logic, please help.
If you want I can post my code tomorrow, I am off today.
Thanks for reading,
Veena
|
|
|
|
|
Personally, I would use three background workers here, one for each upload type and wrap them all in one 'super' background worker class that exposes the required events and methods.
This is a very rough mock up with a lot of gaps to fill but the theory should be OK.
public class Uploader
{
public event EventHandler<EventArgs<UploadProgress>> ProgressChanged;
public event EventHandler<EventArgs<RunWorkerCompletedEventArgs[]>> Completed;
private BackgroundWorker backGroundWorkerData;
private BackgroundWorker backGroundWorkerFile;
private BackgroundWorker backGroundWorkerPhoto;
private RunWorkerCompletedEventArgs[] result;
public void RunAsync()
{
result = new RunWorkerCompletedEventArgs[3];
backGroundWorkerData = new BackgroundWorker();
backGroundWorkerData.WorkerReportsProgress = true;
backGroundWorkerData.WorkerSupportsCancellation = true;
backGroundWorkerData.DoWork += new DoWorkEventHandler(backGroundWorkerData_DoWork);
backGroundWorkerData.ProgressChanged += new ProgressChangedEventHandler(backGroundWorkerData_ProgressChanged);
backGroundWorkerData.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backGroundWorkerData_RunWorkerCompleted);
backGroundWorkerData.RunWorkerAsync();
}
void backGroundWorkerData_DoWork(object sender, DoWorkEventArgs e)
{
}
void backGroundWorkerData_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
OnProgressChanged(
new EventArgs<UploadProgress>(
new UploadProgress(DataType.Data, e.ProgressPercentage)));
}
void backGroundWorkerData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
result[0] = e;
backGroundWorkerData = null;
CheckCompleted();
}
public void CancelAsync()
{
backGroundWorkerData.CancelAsync();
backGroundWorkerFile.CancelAsync();
backGroundWorkerPhoto.CancelAsync();
}
private void CheckCompleted()
{
if (backGroundWorkerData == null &&
backGroundWorkerFile == null &&
backGroundWorkerPhoto == null)
OnCompleted(new EventArgs<RunWorkerCompletedEventArgs[]>(result));
}
protected virtual void OnProgressChanged(EventArgs<UploadProgress> e)
{
EventHandler<EventArgs<UploadProgress>> eh = ProgressChanged;
if (eh != null)
eh(this, e);
}
protected virtual void OnCompleted(EventArgs<RunWorkerCompletedEventArgs[]> e)
{
EventHandler<EventArgs<RunWorkerCompletedEventArgs[]>> eh = Completed;
if (eh != null)
eh(this, e);
}
}
public class UploadProgress
{
public UploadProgress(DataType dataType, int progress)
{
DataType = dataType;
Progress = progress;
}
public DataType DataType { get; private set; }
public int Progress { get; private set; }
}
public enum DataType
{
Data = 0,
File = 1,
Photo = 2
}
public class EventArgs<T> : EventArgs
{
public EventArgs(T value)
{
Value = value;
}
public T Value { get; private set; }
}
|
|
|
|
|
Thanks Dave for all your time and interest.
I will implement the logic and let you know.
Thanks a lot!!!
Veena
|
|
|
|
|
Hi Dave,
I am using only one backgroundworker since I have to upload 3 types of data in sequence , get the confirmation from the web server in loop i. e. for each service Instance. So background worker was uploading the 3 type of data in sequence in foreach loop.
I checked the MainWorker.CancellationPending property before each webrequest. The most time cosuming was photo upload, so I checked MainWorker.CancellationPending between Webrequest and Webresponse. I called RunworkerCompleted right after DoWork and
write these lines
if(eventArgs.Cancelled)
{
MainWorker = null;
}
Now everything works as expected, backgroundworker gets disposed properly and I can upload the data anytime, without exiting and logging in to the application again,
Thanks for all your help,
Veena
|
|
|
|
|
No problem, glad to help.
I thought you were uploading all three simultaneously which is why I suggested thre workers. If it's sequential then just the one is the correct approach
|
|
|
|
|
Description:
EventType clr20r3, P1 controllerservice.exe, P2 1.0.0.0, P3 4a80352d, P4 mscorlib, P5 2.0.0.0, P6 492b834a, P7 1807, P8 24, P9 system.invalidoperationexception, P10 NIL.
Am getting this error while running my c# application. The application sometimes runs with no errors and sometimes it crashes due to this error. Dont know the reason, can anyone help.
Thanks
Prasanna
|
|
|
|