|
|
I personally use web based (using Silverlight) now even though I'd prefer to develop desktop with WPF. This opens up the app to Mac users as well. Also there's no installation/deployment issues.
WCF with Silverlight and/or WPF will give you simplified communication development including duplex communication for "pushing" data to clients. Note WCF has nothing to do with data extraction. Everything you need to know with samples can be found in the docs: Windows Communication Foundation[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
It depends (doesn't it always), in this case on user count, criticality of 'live' (i.e. does it have to be right now, or will 30s later? a minute later? etc do?) and volume of data which is changed.
You really, really don't want 20,000 records in the front end at once. That much data is not parsable by a human, and if you throw that at your users they will just press 'Reconcile' without reading it properly.
It sounds like you're backing onto a database already, so stick with that. I'd use a server-side business layer which handled requests and talked to the database, and also managed updates. Whether to do that as a simple web app with AJAX and polling for updates (with the server maintaining some kind of memory of when it last updated a client and what it's looking at) or a standalone server app hosting a TCP server which pushes updates (again, only sending data that is currently active in a client) depends on the questions above, and also whether web/desktop is specified in the requirements.
|
|
|
|
|
Not sure it it the right forum .. anyway forgive me
I was using VS2010 UML Class Diagram
Adding many "operations" to a class, apparently I'm not able to decide the visualization sorting. So if I have a sequence of operations (let's say:
+Operation1()
+Operation2()
+Operation3()
I'm not able to change order, like
+Operation3()
+Operation1()
+Operation2()
I did not find any help on msdn
Thanks for your time
|
|
|
|
|
1) This is not really the right forum.
This is the C# forum.
2) If you are adding methods in a class diagram, you really need not worry about the order (unless there is some specific reason you want to).
The order in which these methods is called is important in the sequence diagrams.
|
|
|
|
|
The reason is that I was doing a .doc with a UML pasted. The sequence of operations have a logic meaning in the .doc. Many software like StarUML allow you to sort +Operation(), I thought VS2010 was able too. No problem.
Thanks a lot
|
|
|
|
|
Greetings Gurus,
The problem:
"The variable name '@Tstamp' has already been declared. Variable names must be unique within a query batch or stored procedure."
Guesstimate cause:
The data in the variable '@Tstamp' is not being released
The code
SqlCommand inst = new SqlCommand("INSERT INTO dbo.DrvInfo(Tstamp)" +
"VALUES (@Tstamp)", DrvInfo);
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo d in drives)
{
Console.WriteLine(d.Name);
Console.WriteLine(d.DriveType);
if (d.IsReady == true)
{
string label = d.VolumeLabel;
if (label.Length == 0)
label = "No Label";
Console.WriteLine(d.VolumeLabel);
Console.WriteLine(d.AvailableFreeSpace / 1024000000);
Console.WriteLine(d.TotalSize / 1024000000);
DrvInfo.Open();
inst.Parameters.Add("@Tstamp", SqlDbType.NVarChar, 50).Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InstalledUICulture);
inst.ExecuteNonQuery();
DrvInfo.Close();
}
else
Console.WriteLine("uh oh");
}
The question:
In iterating through the values of the foreach, how do I dispose of the first set of collected data so that the next set can be written to the table?
Can you help please? Do I need to declare each variable as "Nothing" before restarting the loop?
|
|
|
|
|
You can only ADD the parameter once. So add it before the foreach loop, not inside it (And without the .Value = part)... Then, inside the loop, do something like:
inst.Parameters["@Tstamp"].Value = DateTime.Now.ToString.....
|
|
|
|
|
Hi Ian,
I still trying to figure a lot of this stuff out so thank you, it's working now.
If I may ask, there are quite a lot of parameters to add so is there a more efficient way of writing
inst.Parameters.Add("@Tstamp", SqlDbType.NVarChar, 50);
inst.Parameters.Add("@SysID", SqlDbType.NVarChar, 5);
inst.Parameters.Add("@Drive", SqlDbType.NVarChar, 5); ?
Something along the lines of
inst.Parameters.Add(("@Tstamp", SqlDbType.NVarChar, 50)&("@SysID", SqlDbType.NVarChar, 5)& ("@Drive", SqlDbType.NVarChar, 5);
I know '&' is the wrong operator but I am using it to illustrate an idea.
Thanks again,
|
|
|
|
|
Not that I'm aware of. I mean, you could put together an array of field names, an array of data types, and an array of sizes, but I doubt you want to go through all that.
In my system, I actually wrapped command objects a custom DBCommand class, so instead of adding parameters manually, I had the constructor parse out commands like in a string.Format... So in your case, I would do something like:
INSERT INTO dbo.DrvInfo({{s:Tstamp/50}}, {{s:SysID/5}})
And with a little regular expression parsing, the DBCommand constructor would replace those codes with parameter names, generate the parameter objects, etc.
Can't post the actual code, though... Proprietary... Ya know...
|
|
|
|
|
Thanks Ian,
I was thinking along the same lines but, considering I have 7 entries in the loop and another 5 entries in another loop, the lines of code used wrapping the objects is actually greater than the way I was doing it initially (counting declarations etc.).
I think it will be easier to just keep doing it the way I was.
Thanks for the help anyway.
|
|
|
|
|
Nice. Didn't know you could do that.
|
|
|
|
|
Yeah, what Ian said.
Also...
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss" don't store dates as strings, use DateTime.
|
|
|
|
|
Hi again PIEBALDconsult,
I had to because I could find no other way to get my date to display as 2011-10-14 22:14:00. It kept reading as 14-10-2011 22:14:00.
I need it to do this for the purpose of sorting by date.
|
|
|
|
|
CCodeNewbie wrote: I need it to do this for the purpose of sorting by date.
No you don't.
CCodeNewbie wrote: display as 2011-10-14 22:14:00
Then format it when you display it, not when you store it.
And/or set your Region and Language settings in Control Panel properly (which is what I do).
|
|
|
|
|
Region and language settings are as they should be.
The front end is a MS Access mdb with long, medium or short date options, none of which put the year first unless I format it using built-in vba code.
I would therefore rather code it at source.
Is there a reason you are against outputting DateTime to string?
|
|
|
|
|
CCodeNewbie wrote: outputting DateTime to string?
No, I (and most experienced practitioners) are against storing DateTimes in strings.
CCodeNewbie wrote: The front end is a MS Access
Yuck.
CCodeNewbie wrote: unless I format it using built-in vba code.
Then do so.
|
|
|
|
|
OK, you win. I'll store the Datetime correctly
|
|
|
|
|
|
As PIEBALD already said:
1.
strings are intended for holding text, i.e. sequences of characters that don't have any particular meaning the computer may be interested in. Dates and times, integer numbers, real numbers, all have their proper types, both in programming languages and in SQL and other databases.
2.
The DateTime types in the database allow for sorting chronologically, as well as for date operations (there are functions to get to date parts: year, month, etc).
3.
formatting data is a job of the front-end program, not the database. A database just holds the data, without worrying aboiut formatting; you don't want to modify your database just because someone wants a different format; and what if different users want different formats? You don't store numbers as strings, for the sake of e.g. forcing leading zeroes; if that is what you need, get your code to deal with it. Similarly, you don't store dates and times as strings, they are inherently numbers, no more, no less.
4.
When writing SQL commands that need literal values, always use parameters, never have literal values in your SQL string itself. (You seem to be doing that right already).
5.
Never deviate from the above, it will bite you very badly.
|
|
|
|
|
|
=3628800
|
|
|
|
|
Does anyone have any code where I can read a 64bit registry key, remotely from a 32bit c sharp (.net 3.5) application?
I've seen RegOpenKeyExW, but that appears to be just for local and I need to do this remotely.
Thank you.
|
|
|
|
|
This[^] contains example on to read 64-bit registry information from a 32-bit application.
The example is for the local machine, but you should be able to convert it to read from remote machines by using RegConnectRegistry[^].
The first link also shows how it can be done with .NET 4.0, which is a lot easier.
Hope this helps.
0100000101101110011001000111001011101001
|
|
|
|
|