|
|
Member 10878790 wrote: we can't create instance of abstract class
That's why.
Some base classes can be used on their own, others can't -- if a base class is unusable by itself, and you don't want anyone to instantiate it, then mark it abstract. You don't have to (unless it contains abstract members), but it shows intent.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I am changing the timezone and want to display the zone like this 1/14/12 4:52:50 AM PST
with the code i am not able to get exactly the output that i want. How can i get time along wit PST in the end
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var offset = timeZoneInfo.GetUtcOffset(DateTime.Parse(newRX.Header.SentTimeOffset));
var dto = new DateTimeOffset(DateTime.Parse(newRX.Header.SentTimeOffset), offset)
|
|
|
|
|
There's no real inbuilt mechanism for writing out an abbreviated TimeZone. You might want to try this[^] library though.
|
|
|
|
|
Hi,
I would like to ask the following:
I have a client who has a PC used for front office.
At the front office, he wants to keep LCD showing his products.
Is it possible to have my .net application running on the front office PC and display the products on the LCD (let’s call it PromoLCD) without interrupting the front office work? So users will continue using the front office PC for their own applications, work, excel, etc but only my application will be shown on PromoLCD?
Is this possible?
What’s your advise?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
I wouldn't: any accidental "slip" by the front office users could result in an...um...unwanted...display.
Have you considered looking at something like a video file, or a photo slideshow? Use anything with HMDI and you could plug a Chromecast in and stream anything you wanted to it. Or most TV's now include a USB connector from which you could do much the same thing.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
It's possible not not a wise thing to do.
It's not so much this application screwing with the user of the machine, but the other way around.
This is normally done as a seperate, usually secured, workstation that is attached to it's own monitor and this LCD (monitor). The displays are setup so they mirror each other. What you see on the local monitor is what you see on the remote monitor.
Where I work, there's dozens of large format monitors spread throughout various areas that display company news information. They are all driven off a single PC that is connected to both a local monitor and a video system that all of these monitors are connected to. Bascially, its kind of like our own internal cable TV network.
|
|
|
|
|
A place I used to work at had LCD displays onto which you uploaded data to be displayed, which was stored in the display's internal memory. The PC was only needed for a short time to set up the data to be displayed, then upload it to the display.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I Connect to a MySql Server from my C# Winform Application and I use a DataReader and the Convert Method to read a DateTime variable from the DB and convert it(No Errors).
DateTime date = Convert.ToDateTime(rdr["LastContacted"].ToString());
However when I wish to display the DateTime fields from my DB in a DataGridView
I receive the error "Unable to convert MySQL date/time value to System.DateTime".
string sql = "SELECT ID,";
if (chbxName.Checked) sql += "MemberName, ";
if (chbxSurname.Checked) sql += "MemberSurname, ";
if (chbxCellNumber.Checked) sql += "CellNumber, ";
if (chbxTellNumber.Checked) sql += "TellNumber, ";
if (chbxEmail.Checked) sql += "Email, ";
if (chbxStreetAdress.Checked) sql += "Street, ";
if (chbxSuburb.Checked) sql += "Suburb, ";
if (chbxCity.Checked) sql += "City, ";
if (chbxOccupation.Checked) sql += "Occupation, ";
if (chbxTitle.Checked) sql += "Title, ";
if (chbxInitials.Checked) sql += "Initials, ";
if (chbxDateJoined.Checked) sql += "DateJoined , ";
if (chbxDateResigned.Checked) sql += "DateResigned, ";
sql = sql.Remove(sql.Length - 2, 2);
if (Type == "resignedmembers")
sql += " FROM resignedmembers";
else
sql += " FROM members";
sql += " WHERE MemberType = '" + Type + "' AND " + FilterParameter + " LIKE '%" + txtFilterQuery.Text + "%' ";
MySqlDataAdapter daClients = new MySqlDataAdapter(sql, cnManageMembers);
daClients.Fill(dtClients);
BindingSource bsClients = new BindingSource();
bsClients.DataSource = dtClients;
dgvClients.DataSource = bsClients;
bnClients.BindingSource = bsClients;
dgvClients.Columns[0].ReadOnly = true;
How do I resolve this and do I resolve it in my Application or DB?
Thank you for your time.
|
|
|
|
|
"DateTime date = Convert.ToDateTime(rdr["LastContacted"].ToString());"
Don't do that; just cast the value:
DateTime date = (DateTime) rdr["LastContacted"];
However, MySql is able to store "zero dates":
mysql> SELECT MIN(`acquisition`) FROM `v_array`
-> ;
+--------------------+
| MIN(`acquisition`) |
+--------------------+
| 0000-00-00 |
+--------------------+
1 row in set (0.05 sec)
which can be neither represented in a .net DateTime nor stored in Sql Server
System.Data.DataException: Exception encountered in ExecuteDataTable ---> MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime
I have had to deal with this many times over the last couple of years (Oracle's Date type also exceeds what Sql Server can hold) so what I do is test and replace with NULL:
, CASE WHEN `acquisition`<'1753/1/1' THEN NULL ELSE `acquisition` END `acquisition`
'1753/1/1' is the minimum date that Sql Server (2012) can hold.
http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqldatetime(v=vs.110).aspx[^]
You may choose a different date if you like.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
PIEBALDconsult wrote: I have had to deal with this many times over the last couple of years (Oracle's Date type also exceeds what Sql Server can hold) so what I do is test and replace with NULL:
, CASE WHEN `acquisition`<'1753/1/1' THEN NULL ELSE `acquisition` END `acquisition`
Thank you, understood.
However how would I implement this? do I add the above code to my sql statement?
|
|
|
|
|
How about:
if (chbxDateJoined.Checked) sql += "CASE WHEN DateJoined < '1753/1/1' THEN NULL ELSE DateJoined END DateJoined , ";
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
|
PIEBALDconsult wrote: However, MySql is able to store "zero dates" Even worse: February 29 is valid for any year (not restricted to leap years), and any month can have 31 days, and a day or month number of 0 is also valid (at least with older versions of MySQL, not sure about the current version).
|
|
|
|
|
Hadn't seen that. And it also seems that it only does Unicode. Fortunately, I only have to deal with one source in MySql.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I am trying to get bytes sent and received in a Windows Store App but I am always getting bytes sent/received as zero. Code snippet is shown below. Any help/hint is highly appreciated, thank you
ConnectionProfile connectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (connectionProfile.NetworkAdapter.IanaInterfaceType == (int)EnumMediaType.WiFi)
{
NetworkUsageStates nus = new NetworkUsageStates();
nus.Roaming = TriStates.No;
nus.Shared = TriStates.Yes;
TimeSpan TimeDiff = new TimeSpan(1, 0, 0);
IReadOnlyList<NetworkUsage> listNetworkUsage = await connectionProfile.GetNetworkUsageAsync(startTime.Subtract(TimeDiff), DateTimeOffset.Now, DataUsageGranularity.Total, nus);
for (int i = 0; i < listNetworkUsage.Count; i++)
{
textBoxMediaType.Text = string.Format("Sent: {0}, Received: {1}, Duration: {2}", listNetworkUsage[i].BytesSent, listNetworkUsage[i].BytesReceived, listNetworkUsage[i].ConnectionDuration);
}
Note: I am using IE in the background to download some pages to ensure that bytes are sent/received.
modified 11-Jun-14 9:38am.
|
|
|
|
|
What is the value in startTime?
|
|
|
|
|
Value of startTime is 5 minutes lesser than app start time which gets set in MainPage() ctor. Code shown below:
public MainPage()
{
startTime = DateTimeOffset.Now;
this.InitializeComponent();
}
|
|
|
|
|
You shouldn't be using GetNetworkUsage to determine if a single app is actually sending and receiving data. Since there are a ton of other processes running on the system that can talk on the network there is no way for you to know that the traffic you're seeing in those numbers came from your application.
It's returning zeros because the underlying API functions require Windows 8.1 in order to work. RT is apparently not supported. ConnectionProfile.GetNetworkUsageAsync()[^]
|
|
|
|
|
I am actually on Windows 8.1 (sorry for the confusing subject line, I should have written Windows Store App instead). When I changed NetworkUsageStates' Roaming and Shared to DoNotCare I started getting values. Still evaluating to see if the values that I get are correct. I want the complete bytes sent and received, so no issues for me.
NetworkUsageStates nus = new NetworkUsageStates();
nus.Roaming = TriStates.DoNotCare;
nus.Shared = TriStates.DoNotCare;
Note: Thanks for the note that this would not work in Windows RT. This is not good news for me
|
|
|
|
|
I changed the code as shown below and I am getting values. I just changed the NetworkUsageStates value:
NetworkUsageStates nus = new NetworkUsageStates();
nus.Roaming = TriStates.DoNotCare;
nus.Shared = TriStates.DoNotCare;
TimeSpan TimeDiff = new TimeSpan(0, 5, 0);
IReadOnlyList<NetworkUsage> listNetworkUsage = await connectionProfile.GetNetworkUsageAsync(startTime.Subtract(TimeDiff), DateTimeOffset.Now, DataUsageGranularity.Total, nus);
for (int i = 0; i < listNetworkUsage.Count; i++)
{
textBoxMediaType.Text = string.Format("Sent: {0}, Received: {1}, Duration: {2}", listNetworkUsage[i].BytesSent, listNetworkUsage[i].BytesReceived, listNetworkUsage[i].ConnectionDuration);
}
|
|
|
|
|
I have a few for example insert new records, when the store must have "SET IDENTITY_INSERT TabeleName ON"; and "SET IDENTITY_INSERT TabeleName OFF"; other examples do not need 2 lines ON and OFF, if I wanted to give my 2 lines to adjust what ? you see the code below:
strSQL = "SET IDENTITY_INSERT TableName ON ";
strSQL = strSQL + "INSERT INTO TableName(USERNAME";
strSQL = ...
strSQL = strSQL + "SET IDENTITY_INSERT TableName OFF";
...
SqlCommand cmd = new SqlCommand(strSQL,cnn);
try
{
cmd.ExecuteNonQuery();
cnn.Close();
}
....
|
|
|
|
|
Man you are struggling with English, let me see if I can help.
SET IDENTITY INSERT ON will allow you to insert a value into an IDENTITY field, usually a primary key on the table. This is useful if you are moving data from 1 server to another and you have to match ID values.
Under normal circumstances this should NEVER be used. You should be chasing down the business case that required this and find out why it was done.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As per my understanding you are trying to insert few sample records to the database, however I don't understand why you are doing this through code. Or are you trying to read the records from some source and feeding into the database? If that is the case you should use those lines,
SET IDENTITY_INSERT [table_name] ON
SET IDENTITY_INSERT [table_name] OFF
For each records inserts.
Alternatively you can set,
SET IDENTITY_INSERT [table_name] ON
INSERT [table_name] ([ID],,,) VALUES (1,,,)
INSERT [table_name] ([ID],,,) VALUES (2,,,)
....
....
SET IDENTITY_INSERT [table_name] OFF
However, I don't use this inside the Data access layer. I don't set the identity for the record. Set it to Auto increment for best practice.
|
|
|
|
|
When you have column in your table declared as identity field you should not insert value into it. SQL will handle the value for that column!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|