|
This isn't related to C#, so it's in the wrong place.
But it's a rookie mistake, and I'll answer it as a result.
There is but one solution: change your database.
Never store dates in NVARCHAR columns - always use DATETIME or DATE instead.
If you use the wrong column datatype it's easy to set up, and lazy to get the user data into - but it always gives total nightmares after that - because the data in your DB is not valid, or is not in a consistent format, or is in a different format from that which SQL expects.
Think about it: 10/11/12 is a valid date. But is it 10th Nov 2012, 11th Oct 2012, 12th Nov 2010, or some other value entirely? The only time you can tell is when the user inputs the value, and you use his culture to convert it to a DateTime value - as soon as it arrives in the DB it's too late because you no longer have any idea what date format he used: it could be US: MM/DD/YY, European: DD/MM/YY, or ISO / Japanese YY/MM/DD - and you don't even know that the user is using the same calendar as you so the year could be well different (the Hijri date today is Jumada Al-Awwal 3, 1438)! Or even that he didn't enter "hello, my name is Jackie" which isn't even close to a date.
So when you try to convert it to a date at a later time you are almost guaranteed to get errors because the SQL server will try to convert it using it's culture - and generally you don't even know what culture the server is set to!
Always use appropriate data types - it may be easier for your code to slam in NVARCHAR all the time, but it wastes huge amounts of effort later fixing up the holes it leaves.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I tried to convert in single table also containing date format in datetime as 2016-03-31 00:00:00.000.
update invINVOICE set INV_DATE =convert(datetime,convert(datetime,INV_DATE ,(105)))
But still got the same error while running the query.
I already written script for database to convert all the columns to datetime with a format '2016-03-31 00:00:00.000'
Now they want only date format containing dd-mm-yyyy.
Please suggest me solution this time.
|
|
|
|
|
You can't. DATETIME fields don't have a format - they are stored as a number of tick since a preset point in time (for SQL Server, that's "ticks since Jan 1st 1753") so quite what you expect two datetime conversions to do I'm not quite sure.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Everything @OriginalGriff has said but perhaps use Date instead of DateTime . Anything else should be done in the presentation layer.
|
|
|
|
|
TarunKumarSusarapu wrote: Now they want only date format containing dd-mm-yyyy.
Store the values in a datetime , datetime2 or date column. That will store the actual date value, without any associated formatting.
Date and Time Types[^]
Any formatting of the value should be done when you display the date values in your application or report.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried to copy data and changing to DateTime using temp field.But also getting the same error.
alter table GL add GL_DATE1 datetime null
update GL set GL_DATE=convert(datetime,GL_DATE,104)
update GL set GL_DATE1=GL_DATE
alter table GL drop column GL_DATE
SP_RENAME 'GL.GL_DATE1','GL_DATE','column'
please give me the advice to copy data from one field to another field using the temp table.
|
|
|
|
|
You need to take this question over to the database forum. You started off by asking a SQL question here and now you're asking another SQL question.
This space for rent
|
|
|
|
|
Ok Thank you.I will change the message board.
|
|
|
|
|
I'm creating some very large images in .net and i'm using JPEG compression to get the file size down. However, if the image exceeds 65,000(ish) pixels in either width or height, I can no longer use jpeg compression. Is there a max dimensions limit for JPEG?
the exception being thrown is:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
the code that is saving the image:
public static void SaveImage(ref Bitmap b, string fName)
{
long quailty = 75;
ImageCodecInfo jpgEncoder = getEncoder(ImageFormat.Jpeg);
Encoder myEncoder = Encoder.Quality;
using (EncoderParameters myEncoderParameters = new EncoderParameters(1))
{
using (EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, quailty))
{
myEncoderParameters.Param[0] = myEncoderParameter;
b.Save(fName, jpgEncoder, myEncoderParameters);
}
}
}
in the case of the above exception the image is 2,000x100,000 the magic number seems to be in the 65k range, both width and height. Like, I can do 4,000x55,000 but not 2x70000.
|
|
|
|
|
|
Hello. I've tried that, with WritableBitmap and run into the same problem. Raw saves fine, jpeg throw the exception.
|
|
|
|
|
So it also a JPEG limitation as found by Griff.
I would suggest too to use PNG or TIFF instead. They are lossless and allow you to reload the same image which would not happen with JPEG.
|
|
|
|
|
A very quick google says it's a JPG limitiation: Quote: The theoretical maximum of a jpeg image is 65,535 x 65,535 (width x height). This is because the fields containing the height and widths is a word (2 bytes wide, or 16 bits). Any limitation below that, I presume is software limitation, not jpeg standard.
Have you considered PNG format? It is readily interpreted by most browsers and software on most operating systems and it allows theoretical 4,294,967,295 x 4,294,967,295.
(How big (in pixels) can a jpg image file be - Photo.net Digital Darkroom Forum[^])
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Why would you need an image that big, and why can't it be solved with several smaller images representing the same data?
It would still contain the same data, just not have the limitation that it needs to be read as a single entity.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The function of the tool is to load the file handling.meta and display the values of each parameters present in the file (handling.meta) for within each TexBox of the interface of the tool. So when a value (number) is edited in this TexBox will be saved manually by pressing the "Save" or "Save As" button.
With the following features:
* Open, save and save as...
* Interface localization
* Auto/manual application update
among others.
Example of a handling.meta file editing tool similar to the one I want to create:
GTA V Handling Editor - GTA5-Mods.com[^]
Soon, I'll give you more details about it.
|
|
|
|
|
|
KrazyMonkey Modding wrote: Soon, I'll give you more details about it.
No need really. It would appear that you have mistaken us for a free coding service and we are not. You need to go to a website like rentacoder or freelancer where you can hire someone to write your code for you.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
KrazyMonkey Modding wrote: Soon, I'll give you more details about it.
If you're trying to post something akin to an article in the forums, don't bother. It'll be removed in no time at all.
If you want to write an actual article and post that, fine. Just don't treat the forums as your advertising space.
If you wanted to start a discussion with your article, every article has its own forum at the bottom of the article. Post your article and the discussion will be held in that forum, dedicated to your article.
|
|
|
|
|
Are you the "XML flag editor" guy?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
In C#, I have a DataSet populated with about 40 tables.
I need to output the data in this DataSet to an SDF file.
How can I do this?
I’m using SqlCe and have its connection already defined.
Ideas?
Thanks so much :-/
-Mike
|
|
|
|
|
Simmerliner wrote: Ideas? The obvious idea is that you write the SQL statements to create the database and insert the records. What exactly is the problem?
|
|
|
|
|
I'm passing the value of a month over to my View but can't seem to figure out to display it inside my declared dropdown.
<th>Posting Month:</th>
<td>
@Html.DropDownListFor(m => m.PostingMonth, new SelectList(Model.PostingMonth))
@(Html.Kendo().DropDownList()
.Name("ddlPostingMonth")
.BindTo(new List<SelectListItem>()
{
new SelectListItem() { Text = "" },
new SelectListItem() { Text = "January" },
new SelectListItem() { Text = "February" },
new SelectListItem() { Text = "March" },
new SelectListItem() { Text = "April" },
new SelectListItem() { Text = "May" },
new SelectListItem() { Text = "June" },
new SelectListItem() { Text = "July" },
new SelectListItem() { Text = "August" },
new SelectListItem() { Text = "September" },
new SelectListItem() { Text = "October" },
new SelectListItem() { Text = "November" },
new SelectListItem() { Text = "December" },
}))
</td>
This is inside my Controller:
var result = CB.GetAgentDetail(orderNumber).FirstOrDefault();
model.PostingMonth = result.PostingMonth;
ViewBag.PostingMonth = result.PostingMonth;
ViewBag.Overflow = result.Overflow;
model.Tare1 = result.Tare1;
return View(model);
^^^^^^^ The value from the database actually shows when I step through using a breakpoint.
How do I get this value to appear in my dropdown control?
When I try something simple like: @Html.DisplayTextFor(m => m.PostingMonth), it shows the correct value in a textbox.
Please help!!
|
|
|
|
|
how to get data from one web register form at the time of submit button click.
& fill auto when use.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work from.
And without your code to give us a clue ... we can't help you much, if at all.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Message Closed
modified 26-Jan-17 4:35am.
|
|
|
|