|
Hi all,
I am writing a server program for multi-client access in C#,
the server will update, delete, add object onto the database.
I am not quite sure the proper method to handle multi-client access.
There are object layer and database layer in the program, when two clients want to update the same object A to the database via the object layer at the same time, should the synchronization of object be
implemented at the object layer or the database layer ?
What are the considerations to choose which layer to synchronize ?
Are there any reference for these kind of programming ?
Thanks
Patrick
|
|
|
|
|
If you're using Sql Server for the database and two people update at the same time, the second person's update will happily over write the first person's update.
If you have two people working on the same record at the same time in your user interface and you want to ensure when the first person updates the record, that the second person gets notified that there has been a change made since starting to work with the record themselves, then you would probably want to put that into your business logic (object layer). You should put a last update date column into your database table that is being updated and check it before calling the update. You should also save the date/time that the record was opened and check that against the last update on the record. If it has been updated since the current person first accessed it, then you should prompt the user to determine if they want to see what has changed and/or if they want to overwrite it.
Hope that helps.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi and a happy new year!
I like to get the application path (startup path) of my console application (with a windows form it is no problem because I am having the Application object).
How can I do this?
Thank you for your help!
senfgurke.
life is very short and there is no time for fussing and fighting my friend.
|
|
|
|
|
Ah, ok, I found it:
using System.IO;
...
string AppPath = Directory.GetCurrentDirectory();
...
life is very short and there is no time for fussing and fighting my friend.
|
|
|
|
|
From MSDN:
"The current directory is distinct from the original directory, which is the one from which the process was started."
You can change the current directory by setting the CurrentDirectory of the Environment class. This would obviously give you false results if you're trying to get the path to the executing or entry assmebly.
Use Assembly.Location to get the physical path to the assembly in question. You can use Assembly.GetEntryAssembly to get the entry assembly or Assmebly.GetExecutingAssembly to get the assembly from which the current code is executing.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Thank you Charlie.
Yes, I think its the best way.
Just let me add which namespace has to be included:
using System.Reflection;
I also found code at
http://www.devtrain.de/artikel_908.aspx[^]
Senfgurke.
life is very short and there is no time for fussing and fighting my friend.
|
|
|
|
|
Hi all,
I often use "like" operator in VB.NET in my pattern comparision.I spent my time in finding the equivalent in C# but I don't know how.Could anyone tell me how.Thanks for your help!
|
|
|
|
|
You could use code this:
Console.WriteLine( ("TESTING".ToLower().IndexOf("sti") > 0) );
But when you work with patterns, you really should use Regular Expressions, if you are not familiar with Regex, then this should be a good reference: http://www.codeproject.com/useritems/RegexTutorial.asp[^]
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi
Is there any problem if 2 threads use the same database SQL Server CE 2000 connection do transaction at the same time?
If 1 threads capture the right to do the transaction, then is the other thread will wait for access or what others happen?
Thanks
|
|
|
|
|
How can i package a project (included SQL database)?
Thanks!
|
|
|
|
|
Do you mean how can you create an installer that will install database objects?
Here is a pretty good overview of how to create an installer with a custom action assembly: http://www.c-sharpcorner.com/Code/2003/Dec/CustomInstallMG.asp[^] . It is in the custom action assembly that you will add your code to run a script to generate database objects (I'm assuming you're using Sql Server). You can just include a .sql script in your installation project and open that file and run it with ADO .NET during the installation process.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I can't open your link. Can't you check it for me.
Thanks a lot!
|
|
|
|
|
I tried to just change the link in the original message, but it wouldn't work so here it is again: http://www.c-sharpcorner.com/Code/2003/Dec/CustomInstallMG.asp[^]
There was a trailing slash for some reason.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
The link works now
Thanks a lot!
|
|
|
|
|
The link works now.
Thanks a lot!
|
|
|
|
|
Hi,
I'm trying to achieve IE style Back/Forward Button control in a windows form. Does Visual Studio.Net has this built in ?
That is, if you look at Internet Explorer, the Back Button actually has two parts. The back button itself, and then the downward arrows is actually a drop-down form. So, a two-in-one control.
Please Advice.
Stanley
|
|
|
|
|
.NET 2.0 (currently in open beta) has this in the form of a ToolBarButton .
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
Hello,
I'm looking for a checked combobox which I can use on a search form.
Basically I want to search for "items" with one or more statuses and using a checked combobox would be a compact way of allowing users to do that.
But I haven't found one yet... Couldn't even find one on CodeProject
Anyone seen one out there?
Thanks in advance,
Daffrey
|
|
|
|
|
First off, I've got to say that you should really do a web search before asking questions. This is not hard to find. Google is your friend.
That being said, there is a native control in .NET called CheckedListBox. It isn't a combo, but will get the job done. Having checkboxes in a combo is a little counter intuitive, anyhow (which is why Microsoft doesn't provide one). Take a look here to learn more about the CheckedListBox: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboricheckedlistboxctltasks.asp[^]
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Thanks for the reply.
Google normally is my friend and I always turn to it first before posting questions anywhere, but I have searched on Google several times trying to find a checked combobox for .NET and have come up with zero every time.
I've searched on 'checked combobox', 'checked combobox .net', '"checked combobox" .net'.
I've found references to checked comboboxes for Access and there are several C++ versions around, and COM components around but I still haven't found one written in C# or VB.NET.
I'm sure there is one out there somewhere for .NET.
As for the CheckedListBox, I already know about that but it is not what I am after... Although I may yet have to utilise it by displaying it when a button is clicked on to simulate a drop down.
By the way...what is counter intuitive about a checked combobox? As long is there are not too many entries they are very good and for my purposes there wouldn't be anymore than 30 items.
Don't get me started on what Microsoft provide in their "Standard Control" offerings... they can't even get a DatePicker (Handling Null Dates) or a TabControl (Can't hide tabs, Can only insert tabs at the end) right in .NET .
Anyhoot,
The search goes on...
Daffrey
|
|
|
|
|
I guess the bottom line is that if you don't like the Microsoft way, you've gotta write your own.
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi,
I want to create a gradient toolbar, which inherrits from System.Windows.Forms.ToolBar.
The gradient is drawn correctly, but unfortunately it covers all buttons I've added to the toolbar... so I got the gradient but no displayed buttons at all.
Here's my code (GradientToolBar.cs) :
using System;<br />
<br />
using System.ComponentModel;<br />
using System.Drawing.Drawing2D;<br />
using System.Windows.Forms;<br />
<br />
namespace Controls<br />
{<br />
public class GradientToolBar : System.Windows.Forms.ToolBar <br />
{<br />
<br />
<br />
private System.ComponentModel.Container components = null;<br />
private Color gradientColorA = SystemColors.Control;<br />
private Color gradientColorB = Color.LightGray;<br />
private LinearGradientMode gradientMode = LinearGradientMode.Vertical;<br />
<br />
public Color ColorA<br />
{<br />
get { return gradientColorA; }<br />
set { gradientColorA = value; }<br />
}<br />
<br />
public Color ColorB<br />
{<br />
get { return gradientColorB; }<br />
set { gradientColorB = value; }<br />
}<br />
<br />
public LinearGradientMode GradientDrawMode<br />
{<br />
get { return gradientMode; }<br />
set { gradientMode = value; }<br />
}<br />
<br />
public GradientToolBar()<br />
{<br />
InitializeComponent();<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if(components != null)<br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
Rectangle rectangle = new Rectangle(0, 0, this.Width, this.Height);<br />
Brush brush = new LinearGradientBrush(rectangle, gradientColorA, gradientColorB, gradientMode);<br />
e.Graphics.FillRectangle(brush, rectangle);<br />
}<br />
<br />
#region Component Designer generated code<br />
private void InitializeComponent()<br />
{<br />
components = new System.ComponentModel.Container();<br />
}<br />
#endregion<br />
}<br />
}
Can anybody help me with this prob??
Thanks in advance!
Kind regards
dmatz
|
|
|
|
|
Ahh i know your problem...when you choose to override onpaint...you choose to handle all drawing of the visual appearence of the control...what you must do is draw all the items in the controls collection manually in your onpaint function after drawing the background gradient so they appear ontop.
|
|
|
|
|
Hi, thank you for your answer
That's what I thought, too.
But I got no idea, how to draw it on each toolbar button correctly, so that the buttons AND the background are drawn with the gradient.
The buttons got always the form's background while toolbar is drawn with the gradient.
Can you/anybody give me an example how to do that?
Kind regards
dmatz
|
|
|
|
|
got it
If somebody's interested ... contact me!
Kind regards
dmatz
|
|
|
|