|
Hi Guys,
I have a problem though I think it's hard to solve this unless you see the codes. Allow me to share to you and if you have any ideas that can help or comments is most welcome.
I have a tracking system web based program that record a daily activity of a certain operation department. Most of the time 2 or more users are working at the same time from different building. What I',m doing since it's a header/ detail information everytime they create new record and fill up the detail part I saved the record straight to our SQL database using a temporary key then when the USER PRESS a SEND BUTTON what I do is update the TEMP KEY with the original key of a record. The problem is that IF two users do this at the same time sometimes I get the other information record so when I open the file the next time for checking there is inconsistency of record because I can see that the information on the screen is supposed to be in the other person. If two page are open at the same time SOMETIMES I saved the page information which is wrong.
I don't used GLOBAL variable, all are local. Any Ideas?
Thanks
/dabuskol
|
|
|
|
|
I think you should consider reviewing your Database structure rather than your application's architecture. A good way for handling concurrent multi-usability would be to provide locks on the tables you are using (e.g. pessimistic/optimistic record or table locks, etc.).
I haven't done this before on SQL Server but I am 101% sure there are ways to handle multiple users.
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
Can someone help me to pass parameters from C# to a .au3 file (with a sample preferably).
Regards,
Abi
|
|
|
|
|
How to merge / include / embed an image file (such as jpg, wmf, etc.) in an Assembly so that the image file is also compiled inside the Assembly executable itself, instead of keeping the same as an outside file.
Keeping an image file outside the Assembly requires the presence of the image file alongwith the executable, causing error if the user has by mistake deleted the image file.
|
|
|
|
|
Have a look here[^].
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
1) Create a resource file using ResEditor.
2) Using AddExistingItem option of the project add the resource file to the project and Build the application.
3) Use the ResourceManager class to retrieve these resources (use getstring and GetObject methods).
Thanks and Regards
SGS
|
|
|
|
|
Hi,
Can someone help me to pass parameters from C# to a .au3 file (with a sample preferably).
Regards,
Abi.
|
|
|
|
|
I've finally gotten my Crystal Reports to work with a DataSet. However, I am now facing a new problem.
I created a packing list in Crystal Reports, but now we need to be able to modify how the interface reacts based on data in the report - hence, the need for using a DataSet. Because of the amount data involved, the same data that is collected in the C# and passed as a parameter field to Crystal, is being used in a WHERE clause to limit the amount of data pulled into the DataSet (if we pulled everything into the dataset every time, we would be pulling 300-500 orders 400-700 times a day - too much load.)
The problem with this approach is that the DataSetis limited to the particular order that a box belongs to. Each time they try to process another box, it starts from scratch (theoretically). However, it only seems to work on the first box because something is keeping stale data. I tried disposing the dataset and dataadapters at the beginning of each try, refreshing the report object before and/or after setting the datasource method, and refreshing the reportviewer object before and/or after setting the reportsource method. All to no avail.
At this point I'm at a loss as to what to do to refresh the data so that I'm not using stale data each time I run the report. Any ideas would be greatly appreciated.
--In a world without fences, who needs Gates?
|
|
|
|
|
I wrote a class that binds a specific property of a control to Properties in another class. For example, given the class below:
<br />
public class MyClass<br />
{<br />
public int MyProperty<br />
{ get {
{ set {
}<br />
I can bind the SelectedIndex property of a ComboBox to MyClass.MyProperty
It all worked great until I run into properties that return enumerated types.
I looked at the IL code of my classes and the enumerated types are int32 so when I call the PropertyInfo.SetValue method with the value casted to int32 my program still crashes. The error I get is System.ArgumentException "Object type cannot be converted to target type".
I did try using Whidbey and it works, but I can't wait until it gets released.
Following is my code:
<br />
private void SetPropertyValue(object obj, string propertyName, string val)<br />
{<br />
Type objectType = obj.GetType();<br />
PropertyInfo propInfo = objectType.GetProperty(propertyName);<br />
string dataType = propInfo.PropertyType.FullName;<br />
<br />
if (dataType == "System.Integer" || dataType == "System.Int32")<br />
{<br />
propInfo.SetValue(obj, Convert.ToInt32(val), null);<br />
}<br />
else if (dataType == "System.Decimal")<br />
{<br />
propInfo.SetValue(obj, Convert.ToDecimal(val), null);<br />
}<br />
else if (dataType == "System.String") <br />
{<br />
propInfo.SetValue(obj, val, null);<br />
}<br />
else<br />
{<br />
Int32 val2 = Convert.ToInt32(val);<br />
propInfo.SetValue(obj, val2, null);
}<br />
}<br />
|
|
|
|
|
You can't set a property whose type is enum to an int. You have to convert it to an enum type. The best way to do this is to get the type of the property you are SETTING, using PropertyInfo.PropertyType. Then, using that type, get the TypeConverter from the TypeDescriptor.GetConverter. Test for "CanConvertTo", and if successful, to a ConvertTo and pass the resulting object to the SetValue method.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Marc,
Thanks a lot for your help.
I couldn't do a conversion from integer, but interestingly enough I was able to convert from string and the problem got solved. The code below has the fix.
<br />
else if (propInfo.PropertyType.IsEnum)<br />
{<br />
TypeConverter tc = TypeDescriptor.GetConverter(propInfo.PropertyType);<br />
if (tc.CanConvertFrom(Type.GetType("System.String")))<br />
{<br />
object valToSet = tc.ConvertFromString(val);<br />
propInfo.SetValue(obj, valToSet, null);<br />
}<br />
else throw new Exception and figure out next problem<br />
}<br />
|
|
|
|
|
rudy.net wrote:
I couldn't do a conversion from integer
If the "number" is a string, like "5", then it should still do the conversion to the enum type. At least, so it says in the docs for Enum.Parse, which the type converter should be using.
In general, you should be able to convert any value type to a string, and then be able to convert it to the appropriate property type. Otherwise, things like MyXaml wouldn't work.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
I would like to invoke any control's event just as if the user or another source would. This, of course without building my own derivated class.
I've been looking around but i just don't seem to find the answer.
I tried the following but didn't work.
//What i'm trying to do here is to invoke a form's or a control's event by code. The idea seems right but i just could get it to work.
Form1 _fasoc = new Form1();
Type f = _fasoc.GetType();
System.Reflection.EventInfo ev = f.GetEvent("DoubleClick");
System.Reflection.MethodInfo minfo = ev.GetRaiseMethod();
//minfo gets null but the event is recognized. What's wrong?
minfo.Invoke(_fasoc, new object[]{this, new EventArgs()});
If anyone knows about this, please help me out, i'd appreciate it.
|
|
|
|
|
Why would you want to invoke an event when it is not supposed to fire? I just don't get it...
Is it because you want to be able to reuse the code contained in that event? Cause if this is the case there are other ways to implement it, rather than trying to fire an event when it is not supposed to.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hotlinux wrote:
I would like to invoke any control's event just as if the user or another source would. This, of course without building my own derivated class.
If you want to use reflection, get access to the "Onxxx" protected method and call it, rather than trying to extract the EventInfo. The problem with GetRaiseMethod is it doesn't handle multicast events, which is what all the controls use. It'll return a null, because more than one handler can be assigned to something like a Click event.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
|
leppie wrote:
AFAIK GetRaiseMethod() is not implemented for C#.
Out of curiosity (well, actually, more than curiosity), is there any way to get the methods assigned to a multicast delegate?
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Here is an example (in .NET 2, i think DynamicInvoke's args is different in .NET 1):
class Program
{
event EventHandler SomeEvent;
EventHandler SomeHandler;
static void Main(string[] args)
{
Program p = new Program();
EventHandler eh1 = new EventHandler(p.Method1);
EventHandler eh2 = new EventHandler(p.Method2);
EventHandler eh3 = new EventHandler(p.Method3);
EventHandler eh4 = new EventHandler(p.Method4);
p.SomeEvent += eh1;
p.SomeEvent += eh2;
p.SomeEvent += eh3;
p.SomeEvent += eh4;
p.SomeHandler += eh1;
p.SomeHandler += eh2;
p.SomeHandler += eh3;
p.SomeHandler += eh4;
p.FireEvent();
p.FireHandler();
Console.WriteLine("Invoke event");
foreach (Delegate d in p.SomeEvent.GetInvocationList())
{
d.DynamicInvoke(p, EventArgs.Empty);
}
Console.WriteLine("Invoke handler");
foreach (Delegate d in p.SomeHandler.GetInvocationList())
{
d.DynamicInvoke(p, EventArgs.Empty);
}
Console.ReadLine();
}
void FireEvent()
{
Console.WriteLine("FireEvent");
if (SomeEvent != null)
{
SomeEvent(this, EventArgs.Empty);
}
}
void FireHandler()
{
Console.WriteLine("FireHandler");
if (SomeHandler != null)
{
SomeHandler(this, EventArgs.Empty);
}
}
void Method1(object sender, EventArgs e)
{
Console.WriteLine("Method1");
}
void Method2(object sender, EventArgs e)
{
Console.WriteLine("Method2");
}
void Method3(object sender, EventArgs e)
{
Console.WriteLine("Method3");
}
void Method4(object sender, EventArgs e)
{
Console.WriteLine("Method4");
}
}
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
I have that same code in my MxEventPool! How easily we forget code already written!
Now if only I can remember why I wanted something like this!
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
The firing event idea (or problem) came to me when i wanted that a control from one form fired an event of the other.
---------------------------------------------------------------------------
Answer To Polis Pilavas:
Yes one of the reasons i would like to fire up an event is to reuse the code.
Of course there are other ways like this but they dont always work.
_Event(object sender, .....)
{
Do_Something();
}
Do_Something()
{
........
}
But then it's no fun. Or what other forms were you thinking about?
-------------------------------------------------------------
Answer to Marc Clifton:
You mention that i could use the OnXXX protected methods, they are protected, that means i can't just call them, i have to have a derivated class so i can use them.
You also say GetRaiseMethod is only good for single-delegates, that sounds kind of logical but leppie says its not implemented in C#. :????!!!
It would be nice to fire up events by code, Visual Basic 6.0 had some of that.
I remember something like a Do_Click method and i remember using it from time to time.
By invoking delegates and events like you proposed, do they really simulate the same procedures just as if the user or the system had fired them up?
Ill try what's written
Thanks for everything
|
|
|
|
|
hi all;
I am trying to connect sql server2000 with asp.net(C#).
but nothing happens.
Actual problem comming from connection string which is not coming to solve
my code is as follow:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Page language="C#" %>
void Page_Load()
{
string my="workstation id=HOME;packet size=4096;integrated security=SSPI;data source=HOME;persist security info=False;initial catalog=PrintQuota";
SqlConnection mycon=new SqlConnection(my);
try
{
mycon.Open();
TextBox1.Text="Connection opend successfully";
mycon.Close();
}
catch (Exception g)
{
TextBox1.Text=g.ToString();
}
}
The main problem is with user id and password,, i have also checked with integrated security=SSPI but no way to connect..the same string i use in window application but its work but here in web app its not working
error message from exception is
error
System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.UserInfo_aspx.Page_Load() in http://localhost/WebApplication1/UserInfo.aspx:line 16
plz solve my problem . i m waiting for replies.
with regards Ishtiaq
|
|
|
|
|
Since you're using integrated security and ASP.NET is running under the NT AUTHORITY\NETWORK SERVICE account (must be IIS6 on Windows Server 2003), the SQL Server won't authenticate it you because 1) it doesn't have an account added for that user account, and 2) because NETWORK SERVICE is a local account - not a domain account. If SQL Server is on your web machine, you could get away with doing that, but it won't work if it's on another machine.
Either use a specific username and password (typical on web machines) or impersonate a user. You can do this using the <identity> element in your application's (or web site's) Web.config file. You could also impersonate any requesting user and let SQL Server decide if they can query the data. It really depends on your requirements.
To encrypt the connection string with the username and password in the registry and have ASP.NET use that instead of putting the plain-text string on the server, read http://support.microsoft.com/default.aspx?scid=kb;en-us;329290[^].
In the future, however, please post ASP.NET-related questions to the ASP.NET[^] forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc.
Thanks for any help.
-Sam
|
|
|
|
|
sammyh wrote:
What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc.
Insert a column into the underlying DataTable and number it?
Well, that's one idea. Probably not the best.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
The problem with that is once you sort the data your "row numbers" are off. Note that you must use the DataView 's view of the row, not the DataTable . Through the CurrencyManager this is typically pretty easy, but I still don't know of a decent way off the top of my head to display and manage that data in a DataGrid . Thank goodness for the DataGridView[^] in .NET 2.0.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|