|
|
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.
|
|
|
|
|
Hi, I am trying to use PathGradientBrush in my C#/WPF application, but I keep getting error "The type/namespace PathGradientBrush not found".
Is that specificit to a particular .Net version?
Thanks!
|
|
|
|
|
PathGradientBrush is a Windows Forms brush, not a WPF brush. You cannot apply it in WPF.
|
|
|
|
|
|
hi to friends
how to load contact list(jabber xmpp) in listview with status icon? wpf dont have image list...!
i use this code in windows form application :
private void OnPresence(object sender, agsXMPP.protocol.client.Presence pps)
{
if (base.InvokeRequired == true)
{
base.BeginInvoke(new agsXMPP.protocol.client.PresenceHandler(OnPresence), new object[] { sender, pps });
}
else
{
if (pps.Type == PresenceType.available)
{
for (var i = 0; i < listView1.Items.Count; i++)
{
ListViewItem item = listView1.Items.Add(pps.From.User, 0);
}
}
try
{
if (pps.Type == PresenceType.unavailable)
{
for (var i = 0; i < listView1.Items.Count; i++)
{
ListViewItem item = listView1.Items.Add(pps.From.User, 1);
}
}
}
catch
{ }
}
}
ListViewItem item = listView1.Items.Add(pps.From.User, 0); > load online contact with green icon 0
istViewItem item = listView1.Items.Add(pps.From.User, 1); > load offline contact with red icon 1
and can you help me to load contact with status icon In WPF Listview??? like this image :
http://i62.tinypic.com/v7dphi.png[^]">
|
|
|
|
|
Well, I would look to use a DataTemplate to satisfy this need. It would consist of an Image and a TextBlock. Oh, I would also have this data being presented as some form of list to the UI, and bind to that list. Have a look at some samples on MVVM to get some practical examples.
|
|
|
|
|
Recently, I create a mystery number game and i want to add graphic in it. But I create them for console and now I want to add graphic. I have listen that WPF can do that somebody can explain me what is it and give to me link to know how to use?
Thanks
|
|
|
|