|
Hi André
Tried that too... "01/01/0001".
I think the problem is that the parser doesn't recognise 20110325 as a date
If I do this
DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.DateSeparator = string.Empty;
myDTFI.FullDateTimePattern = "yyyymmdd";
string oDate = subKey.GetValue("InstallDate", String.Empty).ToString();
DateTime nDate = DateTime.ParseExact(oDate,"yyyymmdd", null);
Console.WriteLine(oDate);
Console.WriteLine(nDate);
I get this
20110325
25/01/2011 00:03:00
System.FormatException: String was not recognized as a valid DateTime.
|
|
|
|
|
Use 'MM' instead of 'mm'.
'MM' is for months and 'mm' is for minutes.
0100000101101110011001000111001011101001
|
|
|
|
|
Try:
string strDate = "20110325";
DateTime date = DateTime.ParseExact(strDate, "yyyyMMdd", CultureInfo.InvariantCulture); or
string strDate = "20110325";
DateTime date = new DateTime();
if (DateTime.TryParseExact(strDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
{
...
}
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
RegistryKey Regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
{
if (Regkey != null)
{
foreach (string subKeyName in Regkey.GetSubKeyNames())
{
RegistryKey subKey = Regkey.OpenSubKey(subKeyName);
string oDate = subKey.GetValue("InstallDate", String.Empty).ToString();
if (!String.IsNullOrEmpty(oDate))
{
DateTime date = new DateTime();
if (DateTime.TryParseExact(oDate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
Console.WriteLine(date);
}
subKey.Close();
}
produces 25/03/2011 00:00:00
Thanks to everyone for their time
|
|
|
|
|
CCodeNewbie wrote: How do you convert the string 20110325 to a datetime with a "yyyy-mm-dd" format?
Very carefully.
There reason for that of course is because you do not have a "date time".
You have a date.
And there is a difference because a date time has a timezone. Where a date probably doesn't. Or maybe it does. But that is where the 'care' part comes in.
|
|
|
|
|
Good points. C# (or, I should say, the .Net Framework) doesn't have a Date class, though, so he does mean DateTime. It looks like the date is in the same time zone as the application so he shouldn't have an issue with that.
|
|
|
|
|
Hi
For my assignment, want to test out DataRow to insert a new row in to a test table with just one column.
Based on code below I am getting the Data grid populated in the Form, with values in table. But Insert errors out in statement
DataRow dRow = ds.Tables["testtbl"].NewRow();
saying a object reference is missing for dRow. Not sure what the issue is. I thought the NewRow is good enough.
Can you please help to overcome this issue.
namespace SalesAudit
{
public partial class Form1 : Form
{
string strConnection = "Data Source=.;Initial Catalog=Company;Integrated Security=True";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlconn = new SqlConnection(strConnection);
DataSet ds = new DataSet();
string sqls = "select * from testtbl";
SqlDataAdapter da = new SqlDataAdapter(sqls, sqlconn);
sqlconn.Open();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataRow dRow = ds.Tables["testtbl"].NewRow();
dRow[1] = "test";
ds.Tables["testtbl"].Rows.Add(dRow);
da.Update(ds, "testtbl");
sqlconn.Close();
}
}
}
|
|
|
|
|
Got it to work
Had to add the table name testtbl in line below..
da.Fill(ds,"testtbl");
Thanks, Ravi
|
|
|
|
|
or just do
DataRow dRow = ds.Tables[0].NewRow();
i.e. refer to the table as you did a few lines earlier.
|
|
|
|
|
Thanks, your suggestion is the right way to refer to the table instead of giving it a name as I did.
Thanks much it works great now.
|
|
|
|
|
Actually, I'm not sure about that. Giving the table a name means that the lookup will always be the same, even if you change the access to load some other query into ds first. I'd do
da.Fill(ds,"testtbl");
DataTable testtbl = da.Tables["testtbl"];
DataRow dr = testtbl.NewRow();
|
|
|
|
|
I wonder if anyone could help me on adding picture in text box
Sincerely Yours
|
|
|
|
|
This question was already posted in Q&A[^]; please post in one location only.
0100000101101110011001000111001011101001
|
|
|
|
|
You should be stick at one place don't try to Cross post. you can use "Have a question or Comment at bottom of answer" to revert back answerer.
|
|
|
|
|
please do not repost
***** Programme comme si dept soutien technique. est plein de tueurs en série et ils savent adresse de votre domicile. *****
|
|
|
|
|
Hi,
I am looking for some recommendations about an application model I need to generate.
This application will be used by multi-users in multiple locations.
I have Database and I need to display around 20 to 30K records in front end application and also wants to show Live Data as well modified data from database.
What are different technologies I can utilize in DotNet FrameWork?
This is what I came across from my thoughts:
Backend Data Source: Database
For logic and data extraction : WCF
Front End App: Multi-Threaded app (not sure about web based or desktop based.)
Can somebody with experience can guide me?
Regards,
|
|
|
|
|
vjs2445 wrote: This application will be used by multi-users in multiple locations
vjs2445 wrote: Can somebody with experience can guide me?
People usually work on a snapshot of the data, and databases usually don't notify the app that there has been a change in the dataset. Sql Server has the Notification Services, might help.
You could keep everything in memory, using the INotifyPropertyChanged interface, and broadcast all changes to each client. Sh*t happens when two people simultaneous edit my name.
How much users, in how many locations? I don't like the idea of updating a 5Mb blob and sending the new version over the network to a 1000+ users, it might cripple the network very fast, whilst most users aren't even working/viewing that particular blob.
Bastard Programmer from Hell
|
|
|
|
|
Well before this I need to know what are the different concepts and Technologies and different level I can use to fit in this kind of app model.
|
|
|
|
|
This is not a standard application model, due to aforementioned problems, and doesn't happen out-of-the-box.
It'd be wiser to create a webapplication and have it poll using Ajax to show the user the latest snapshot of the data he or she is using right now, as opposed to sending every change to every user, regardless whether they need it or not.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: sending every change to every user
One such app I wrote was for monitoring the activity of a dispatching system I wrote and every user did need to see all the same data. So I had a Windows Service produce an XML file that each client downloaded periodically (every ten to thirty seconds or so, configurable). But there were only around 5000 entries per day.
|
|
|
|
|
Fetching data periodically is a bit different from pushing updates.
..and yes, it's possible to have a console-app that hosts a tcp server, and only send the required updates. That's usually not done for a complete database.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: pushing updates
Well pushing is never a good idea. Polling is the only way, whatever the implementation.
Eddy Vluggen wrote: not done for a complete database
Oh, heck no, only the pertinent information.
|
|
|
|
|
PIEBALDconsult wrote: Well pushing is never a good idea. Polling is the only way, whatever the implementation.
Life isn't that black and white; we built a realtime visualization of a plant, and it worked nicely under that architecture. Then again, that too is very different from making a database update it's clients.
I'd guess that games like World of Warcraft work in a similar way
Bastard Programmer from Hell
|
|
|
|
|
Pushing is sometimes exactly what you want. Only in a web app is it not an option to consider, and that's because it's impossible. In general pushing uses less bandwidth because you only push when there is a change, whereas polling makes lots of 'has anything changed? no' requests.
|
|
|
|
|
I expect that push requires a bunch of "are you still there? yes" messages, so I don't see the difference. Pull also makes it easier for different clients to poll at different intervals. And also allows a button to "get updates now".
|
|
|
|