|
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)
|
|
|
|
|
In order to insert the values in the Identity column, you should use "SET IDENTITY_INSERT TableName OFF" otherwise you didn't require that for every insert command.
|
|
|
|
|
I ran a few examples have must command lines ON and OFF new stored it in SQL Server but a few example other no need 2 lines ON OFF but still be stored in SQL Server, I guess on SQL Server to tune in item no need to use on line 2 (ON OFF), because the examples I ran along one machine, data file attch into SQL Server and i don't moving data from 1 server to another and you have to match ID values.
|
|
|
|
|
I Downloaded a nifty RTF converter here and among all it's features one of them is converting rtf to html. I Copied the code required to convert a rtf stream to html and added all the necessary dll's to my solution, and syntacticaly speaking the code is fine, all except for one line :
void ConvertRtf2Html(Stream rtfStream)
{
RtfInterpreterListenerFileLogger logger =
new RtfInterpreterListenerFileLogger(@"c:\temp\RtfInterpreter.log");
RtfVisualImageAdapter imageAdapter =
new RtfVisualImageAdapter(ImageFormat.Jpeg);
RtfImageConvertSettings imageConvertSettings =
new RtfImageConvertSettings(imageAdapter);
imageConvertSettings.ScaleImage = true;
RtfImageConverter imageConverter =
new RtfImageConverter(imageConvertSettings);
IRtfDocument rtfDocument = RtfInterpreterTool.Interpret(rtfStream, logger, imageConverter);
RtfHtmlConvertSettings htmlConvertSettings =
new RtfHtmlConvertSettings(imageAdapter);
htmlConvertSettings.StyleSheetLinks.Add("default.css");
RtfHtmlConverter htmlConverter = new RtfHtmlConverter(rtfDocument,
htmlConvertSettings);
Console.WriteLine(htmlConverter.Convert());
}
The code below the interpreter comment is where the problem lies - The RtfInterpreterTool.Interpreter Method returns void, not a object of type IRtfDocument. The code block you see above is copied and pasted just as I found it on the page of the developer who coded it, under the example for rtf to html conversion.
How do I proceed now?
Thank you for your time.
|
|
|
|
|
The polite thing to do is ask the author in the forum at the end of tthe article[^]. There's very little chance that Jani will happen on by this question, so you need to ask it somewhere that he gets notified of your problem.
|
|
|
|
|
Hi,
I have a problem with background workers, say that I have at a time 50 bw but the number is reducing as they finish their jobs. The last bw's seems to stuck in their work and I cancel them. In this point (when all canceled or done) I have the processor running at 60-70% and the memory is not cleaned. Some help would be appreciated. Thanks.
|
|
|
|
|
Without seeing any code, this is impossible to diagnose. I would suggest that you download a profiler and run it to see what's not getting freed up.
|
|
|
|