|
You can always use the following
DateTime dt = DateTime.ParseExact(string, "MM/dd/yyyy", null);
string output = dt.ToShortDate();
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
use DateTime.Parse
|
|
|
|
|
Just for example :
string dateStr = "20.01.1980 13:59:59";
DateTime dateTime = DateTime.ParseExact(dateStr, "dd.MM.yyyy HH:mm:ss", new CultureInfo("de-DE"));
Console.WriteLine(dateTime);
|
|
|
|
|
.Net has datetime combined type
SQL Server 2008 has date and time types seperately....
figure out how to use SQL 'Date' type in .net or else write you own class. all the best
Ravie Busie
Coding is my birth-right and bugs are part of feature my code has!
|
|
|
|
|
Hi everyone
First I'm trying to return multiple rows from a table via XML:
string strSQLCommand = "SELECT * FROM Magazalar WHERE Sehir = '" + a + "'";
SqlCommand command = new SqlCommand(strSQLCommand, conn);
TableRowCollection returnvalue = (TableRowCollection)command.ExecuteScalar();
a is cannot be null and the query may return a single row or multiple rows.
then, I want to show this returned row collection in a table:
MagazaShowTable.Rows = returnvalue;
The compiler says that Table.Rows is a Read-Only, and sth cannot be assigned to it, and I couldn't find any suitable option rather than .Rows ...
Can anybody help?
|
|
|
|
|
Hi,
first of all be aware that command.ExecuteScalar() returns the first column from the first row, not multiple rows.
Then as the compiler already says, Rows is a ReadOnly-Property. You could add the rows by using MagazaShowTable.Rows.Add
|
|
|
|
|
Thanks for answering...
So what is the suitable function for calling multiple rows? command.ExecuteReader() ?
I'm converting the returned value to TableRowCollection, is it right?
and how I can I show this row collection in my table?
|
|
|
|
|
ExecuteReader is what you need. The returned value is a SqlDataReader. With this you can iterate through the rows. Simpler approach is to use a dataset with a dataadapter. This will read the rows within a table anyway.
But first you can use ExecuteReader, iterate through the rows and add the rows with values to your datatable.
|
|
|
|
|
I'll give it a try
thank you!
|
|
|
|
|
|
|
|
|
Hey... don't repost your question. You've got the answer. It's an attribute.
To know, what is an attribute, go to GOOGLE or MSDN. Learn first.
|
|
|
|
|
i m getting google results for attribute to a method.
i want to know what exactly is attribute when passed to method parameter.
Sorry for reposting, but plz explain.
Ravie Busie
Coding is my birth-right and bugs are part of feature my code has!
|
|
|
|
|
Its an attribute on the parameter, nothing is getting passed other than the parameter itself.
you can, by reflection find the parameter on the attribute to inspect its value.
The code you have is ,erm, unusual to say the least so I doubt you'll get much help over that you have already. I've been using c# since 2001 and haven't seen parameter attributes except in your post.
I *suspect* that there is a massive and dirty hack in the source code you have. Check the attribute and see if any the attribute code does anything, if so, the orignal programmer pobably intended for the code to be called each time the method is called. That would be appalling however.
|
|
|
|
|
Is your question not answered? What do you want to know exactly?
|
|
|
|
|
Don't repost your questions. It's very rude and drowns out the interesting ones.
|
|
|
|
|
Hi, guys,
How could I make it possible to drag down and select even those parts which are invisible when drag event starts? Similar to Notepad or MS Word tools. Any suggestions would be appreciated!!
Best Regards!
I don't wonder what, but wonder why...
|
|
|
|
|
Leapsword wrote: How could I make it possible to drag down and select even those parts which are invisible when drag event starts?
Drag on what?
What sort of application is it? Windows Forms, ASP.Net, Web; what?
What Controls are you using, what are you dragging on/over?
To get an answer to your problem, you have to describe it fully.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, Henry,
Sorry for my careless mistake. I am still working on Windows Forms Application, and the control I am using now is a TableLayoutPanel, I want to drag over this control, but since there will be also a scrollbar next to this Panel, and this Panel is not showing totally the whole, I am expecting a kind of event which can handle this and if user didn't release the mouse, the Panel can move down as well as the scrollbar scrolls. Is this clear enough now? Your kind help is so much appreciated!
Sincerely
Liang
|
|
|
|
|
Hello everyone
I need to save the word file as PDF.
I am using Microsoft.Office.Interop for that
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
But after it gets saved to the destination folder, pdf doesn't get open,
as the pdf file gets corrupted.
Please help me to do this job done.
Thanks & Regards
Sheetal Rawat
|
|
|
|
|
Hi..
I am new in C#..How we work with CSV files as database..Please send me any article link for CSV fundamental.
Thanks...
Abbas
|
|
|
|
|
|
CSV isn't meant as a database, just as XML or Excell-files. That something is possible, doesn't mean that it's a good idea.
XML and CSV are slow if you treat them as a database, since the layout isn't optimized for that kind of access. Your best bet would be to use database, and export the pieces you need to CSV. If you're looking for something free and simple, consider SQLCE.
That being said, it is possible to read/write CSV data as if it were a database. You'll only need a connectionstring[^]
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
-- Martin Golding
|
|
|
|