|
To me, it's like you have no idea about programming at all. This doesn't answer any questions. You need to tell me what imageList2 is, where it comes from, what you do with it, what MyClass looks like, etc.
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.
|
|
|
|
|
It is very difficult to answer this question without knowing what is in MyClass.
|
|
|
|
|
Hi,
I have written an application to perform a simple CRUD operation i've used MVC design pattern... DAL was designed using the wizard.
I was able preserve the olds value of teh fields of EMployee class using a seperatemethod
PreserveOldValues()
{
//code
}
in the SearchByIndex() i call the fill method and i used the data to initialize the current Employee object also i preserve those values using
PreserveOldValues() the i call update() and internall i pass the preserved values......
However it doesnt do concurrencies and updates... please review my code and give me guidance to fix the problem....
all the required file are in attachemtn and database is in Data.zip file
link to the file:
http://go.internet.com/?id=474X1058&url=http%3A%2F%2Fwww.quickfilepost.com%2Fdownload.do%3Fget%3Df339aa16aea48e9873fa9d9a48747a0e[^]
cheers
|
|
|
|
|
Do you mean this is an ASP.NET MVC project, or is there a winform MVC platform, or did you just write your own MVC code ?
petrericardo wrote: However it doesnt do concurrencies and updates... please review my code and give me guidance to fix the problem....
Perhaps if you asked a specific problem and posted some 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.
|
|
|
|
|
Hi Friend,
thanks for the reply....
the code is bit complex to write in here and explain it at the same time where the problem is. for this reason i've put a link to my source code
Here is the llink to my code
In the above link i have added all the files that you need to test it.... In general, i;ve used teh MVC design pattern (NOT ASP MVC) for creation of a simple employee CRUD operation windows app. Main goal is to test the update and handle of concurrecies.... but neither of them seems to work : (
The primary reason it didnt work in the first place is the use of MVC pattern inwhich i have to use seperate methods to preseve the original data and instead of passing datatables ives passed objects....
please refer to my code for more clarity....i hope : )
thanks
|
|
|
|
|
petrericardo wrote: In the above link i have added all the files that you need to test it.... In general, i;ve used teh MVC design pattern (NOT ASP MVC) for creation of a simple employee CRUD operation windows app. Main goal is to test the update and handle of concurrecies.... but neither of them seems to work : (
MVC does nothing to handle race conditions.
petrericardo wrote: The primary reason it didnt work in the first place is the use of MVC pattern inwhich i have to use seperate methods to preseve the original data and instead of passing datatables ives passed objects....
Why use MVC if it does not solve a problem for you ? In any case, a lot of non MVC code never passes data tables.
petrericardo wrote: please refer to my code for more clarity....i hope : )
I'm sorry, if I have to download and build your code, that's probably something most people are not going to want to have to do. You should do some debugging to get to a point where you can make your problem clearer than that.
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.
|
|
|
|
|
Hi Friend
Christian Graus wrote: MVC does nothing to handle race conditions.
True, but i use a DataSet in the model's DAL i;ve checked and re-checked for bugs but cannot find the issues
Christian Graus wrote: Why use MVC if it does not solve a problem for you ? In any case, a lot of non MVC code never passes data tables.
MVC is used in my previouse projects however, i;ve passed DataTables to caller visa versa.... But this doesnt encapculate the DAL so i shifted passing objects instead.
e.g.: Assume there is a class Employee that has a method SearchByIndex(int iEmpNo){...}
in my previouse style this will return a tblEmployee to the caller
then the Update:
int update(tblEmployee empTable){...} .... works perfectly fine
But my current style this should return a List<employee> collection thus hides the DataSet and it's table tblEMployee
in the update :
int Update(List<employee> empCollection) {....} this doesnt work? DOnt knwo why?
Thanks
|
|
|
|
|
What doesn't work ? Where does it fail to work as you expect?
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.
|
|
|
|
|
The method that preserves the original values does it job.....Update() shows that it doesn't update the database....so the problem is in the update().....
Howeverever, my SQL update statements are generated by the wizard i.e.: "ProcUpdateEmployee"..... This one should work as i never tested the Wizard designed Stored Procedures.... regarless of the conccurrecy handling.... the update of row should happen but it doesnt!
|
|
|
|
|
Hi!
I would like to know whats the best way to display Detail view using ADO.net. In my case I have a product page once clicked on productid i display information regarding this product. there cant be more than one record as i filter based on ID. so in this detail page I am rendering this way
code behind
sqlDataAdapt.Fill(dsProductDetail, "ProductDetail");
if (dsProductDetail!= null)
{
dlProductDetails.DataSource = dsProductDetail;
dlProductDetails.DataBind();
}
aspx
<asp:DataList ID="dlProductDetails" runat="server" width="100%" CellPadding="4" CellSpacing="4" >
<ItemTemplate>
<div class="dlfloatleft">
<%#DataBinder.Eval(Container.DataItem, "ProductId")%><br />
<%# DataBinder.Eval(Container.DataItem, "ProductDesc")%> <%#DataBinder.Eval(Container.DataItem, "ProductCategory")%> <br />
</ItemTemplate>
</asp:DataList>
could anyone please tell me whats the best way I can write code so that even if there is 100000 hits in this page from various geographical location the page performs well? I was thinking may be use datareader and have label controls and set value of those labels but i think using web controls adds overheads to its performance.
please help.
|
|
|
|
|
uglyeyes wrote: sqlDataAdapt.Fill(dsProductDetail, "ProductDetail");
if (dsProductDetail!= null)
{
dlProductDetails.DataSource = dsProductDetail;
dlProductDetails.DataBind();
}
You can't possibly care about scalability if you're not even factoring out your SQL code to a database layer ?
uglyeyes wrote: I was thinking may be use datareader and have label controls and set value of those labels but i think using web controls adds overheads to its performance.
Nothing you can do here will change the hit on your DB, except perhaps if your SQL itself is inefficient and you change it. If you're getting that many hits, you're going to be wanting to be running on a web farm, not a single server.
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.
|
|
|
|
|
And, obviously, this is not the ASP.NET forum. I had to work out you were asking an ASP.NET question from context.
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.
|
|
|
|
|
hello
i am working in windows application the problem is when I execute the exe file the application executes. Without closing the application again i try to execute the exe file my application executes. I cannot let it happen.. Kindly give some ideas so that i can rectify the problem
|
|
|
|
|
In the Main method, Use Process class to determine if an instance of your program is already running. If running then display an Error Message and Close. Otherwise start the Application.
USe the following method to test if the application is running.
public static bool IsProcessOpen(string name)
{
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.Contains(name))
{
return true;
}
}
return false;
}
|
|
|
|
|
You can scan a list of processes but if someone renames the executable file that will not work. On the other hand using a mutex is much more reliable way of checking.
|
|
|
|
|
Hi,
use a Mutex to make your app "single instance". There are several CP articles on the subject, here is one[^] of them.
BTW: do not rely on process names, since they may be changed, and you might not get access to all of them.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
hi sir,
i am working on c# then problem create in datagridview.
so please help me. and my problem this datagridview inside combobox click open new form in c#.
so please help me
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:04am.
|
|
|
|
|
sir ,
any other solution in use for
1. datagridview click cell then display combobox and click combobox then open form inside the datagridview.
please help me
|
|
|
|
|
Hello,
Time to defer to the experts. I have a C# app and a native C++ function in a separate dll. I need to pass a portion of an array by reference to the native code. I've worked with P/Invoke a little bit, but it's still a bit new to me. I've found plenty to P/Invoke examples for passing a whole array, but I haven't found anything specifically for passing a portion of an array. The native function's signature is
void foo(int* arr, int length) and is meant to be called in native C++ like so:
for(int i = 0; i < length; i += stepSize)
{
foo(&arr[i], stepSize);
} I cannot modify the code for foo . From MSDN[^], it looks like to pass the entire array I would use
[DllImport( "nativeLib.dll")]
public static extern void foo([In, Out] int[] arr, int length); and I can call it as
foo(arr, arr.Length);
Now to my question (more like a sanity check). If I want to call foo as in the loop above, should my declaration be
[DllImport("nativeLib.dll")]
public static extern void foo(IntPtr arr, int length); and my call be
unsafe
{
IntPtr unmanagedArr = Marshal.AllocHGlobal(arr.Length * sizeof(int));
Marshal.Copy(arr, 0, unmanagedArr, arr.Length);
for(int i = 0; i < length; i += stepSize)
{
foo(new IntPtr(unmanagedArr.ToInt64() + i), stepSize);
}
Marshal.Copy(unmanagedArr, arr, 0, arr.Length);
Marshal.FreeHGlobal(unmanagedArr);
}
Thanks,
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
dybs wrote:
unsafe
{
IntPtr unmanagedArr = Marshal.AllocHGlobal(arr.Length * sizeof(int));
Marshal.Copy(arr, 0, unmanagedArr, arr.Length);
for(int i = 0; i < length; i += stepSize)
{
foo(new IntPtr(unmanagedArr.ToInt64() + i), stepSize);
}
Marshal.Copy(unmanagedArr, arr, 0, arr.Length);
Marshal.FreeHGlobal(unmanagedArr);
}
Had some time to poke around a bit more and discovered the GCHandle class. My solution is
int[] managedInput = SomeFunctionThatReturnsAnIntArray();
GCHandle arrayHandle = GCHandle.Alloc(managedInput, GCHandleType.Pinned);
IntPtr arrayPtr = arrayHandle.AddrOfPinnedObject();
long arrayAddr = arrayPtr.ToInt64();
for(int i =0 ; i < length; i += stepSize)
{
foo(new IntPtr(arrayAddr + (i * sizeof(int))), stepSize);
}
arrayHandle.Free();
Not sure if the sizeof() part works the same on 32-bit and 64-bit systems, I'll be testing that tomorrow.
What I like about this solution is that I can pass in the address I get from my GCHandle and my managed arrays is directly updated. No calls to Marshal required! Hopefully I'm not missing anything like unsafe context or fixed statment (I think the GCHandleType.Pinned takes care of that). Hope this helps other people.
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
my programe base on WinForm.
It has two buttons,one is "start" the other is "stop".
now i click the "start" button it will excute the code as below:
public void Polling()
{
try
{
...........
Thread[] mythread = new Thread[Count];
for (int i=0; i <Count;i ++)
{
mythread[i] = new Thread(new ParameterizedThreadStart(gatherOnlineTime));
....................
mythread[i].Start(obj);
}
}
catch
{
..............
}
}
now i want to click the button of "stop" to abort the running thread.
how to do it?
Any help will be appreciated!
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:04am.
|
|
|
|
|
thank you stancrm!
But the problem is how can i get the running thread's instance
when i click the other button "stop".
|
|
|
|
|
scoket wrote: Thread[] mythread = new Thread[Count];
Move this code outside the method, i.e., at the class level and use the array to access the threads from your stop method.
|
|
|
|