|
|
That's a nice idea! Something to stick in the Common Lib. ^^
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Ah, i was wondering if there was a existing or simpler way. I could have done it by now ><
I think between that and some extention methods, i can solve the problem nicely.
Cheers!
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Depending on which database you are using, you may see some loss of precision when you store a datetime (aka timestamp in some databases). SQL Server, for example, does not store datetime values to the exact millisecond. It is only accurate to approximately the nearest 3 milliseconds. So if it is important to get accurate timestamps right down to the exact millisecond, you should avoid the SQL Server datetime datatype.
SQL Server 2008 introduces a new datatype, datetime2, which is accurate to approximately 100ns to get around this problem.
Possible solutions:
- if you are using SQL Server 2008 and have ownership of the database, use datetime2 rather than datetime
- if you are not using SQL Server 2008 or you cannot change the table design and if you do not need millisecond accuracy, decide what accuracy you do need: for example, round off your timestamps to the nearest second before storing them
- if you do need millisecond accuracy, either convert the timestamp to a string format (OK for XML, not good for date functions and the conversion to and from datetime type may be slow) or store the timestamp as the number of milliseconds from the epoch (gives you the accuracy you need at a reasonable performance but not good for date functions)
|
|
|
|
|
I'm not too fussed about the loss of precision, i can deal with the nearest second. But thanks for the input. Is there any easy way to round a date? I've always created new dates and copied the relevant values over before.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
One of the earlier replies from Luc shows you how to do this. Yes, you have to create a new DateTime (it is immutable so once you've created one you can't change it) but there is an easy way to do it using AddMilliseconds. Sounds like a good candidate for an extension method if you're at the right version of .NET. Otherwise, a good old fashioned DateUtils class would do.
|
|
|
|
|
|
PIEBALDconsult wrote: May I humbly recommend DateTruncate?
Waiting for V2.0, with a Compare method added to it.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
You'll be waiting a long time if you don't make a request.
I suppose I could make a TimespanTruncate.
|
|
|
|
|
Can I Shutdown my local Computer Using VB.Net?
shinoopmathew@gmail.com
009744931401
|
|
|
|
|
Yes.
Unless you are really fond of spam and viruses, you should not post your email address on a public forum.
People can contact you, as I have done, by replying to your post.
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.”
|
|
|
|
|
Yes. A quick Google Search can get you more guidance on it. Also, as the other poster advised you, refrain from publishing your private info like email address and telephone numbers on forums/webpages.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
|
|
Hi all
i am doing export to excel operation using below code.
public void ExcelExport(System.Data.DataTable tblExportData, string TempFilePath,string userInfo,bool headerStatus)
{
try
{
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Workbooks.Open(TempFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//Writing Header in Excel
if (headerStatus == true)
{
for (int i = 0; i < tblExportData.Columns.Count; i++)
{
excelApp.Cells[7, i + 1] = tblExportData.Columns[i].ColumnName;
}
}
//Writing Data in Excel
for (int i = 1; i <= tblExportData.Rows.Count; i++)
{
for (int j = 0; j < tblExportData.Columns.Count; j++)
{
string colName = tblExportData.Columns[j].ColumnName;
excelApp.Cells[i + 7, j+1] = tblExportData.Rows[i-1][colName];
}
}
//Create a worksheet object
Microsoft.Office.Interop.Excel.Sheets sheets = excelApp.Worksheets;
//from the collection of worksheet select one worksheet
Microsoft.Office.Interop.Excel.Worksheet mySheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(1);
//select the cell in the worksheet
Microsoft.Office.Interop.Excel.Range myCell1 = (Microsoft.Office.Interop.Excel.Range)mySheet.get_Range("A6", "A6");
myCell1.Value2 = userInfo;
myCell1.Font.Color = System.Drawing.Color.Black.ToArgb();
excelApp.Visible = true;
}
catch (Exception ex)
{
}
}
it's working fine in local. but when i deployed this on server(e.g.relience server) then it stops to work. i mean exporting to excel not working. Even it's not generating any error and page is redirecting also. can any one help me please.
thanks to you all in advance.
|
|
|
|
|
This is a cross post. Please ignore.
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 all,
i want to open an existing word document in a folder in the project,path of that file is stored in oracle table.
When i click a link button a query should be executed to take the corresponding path,then with that path the file should be opened.
i tried like this..
Private Sub Linkbutton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Linkbutton6.Click
Dim str As String
Dim command As String = "SELECT FILENAME FROM S_TR_BUILDDATA A WHERE 1= (SELECT COUNT(DISTINCT B.DATEOFBUILD ) FROM
S_TR_BUILDDATA B WHERE A.DATEOFBUILD <=B.DATEOFBUILD) "
Dim DFmenu As DataSet = Me.ExecuteSql(command)
str = DFmenu.Tables(0).Rows(0).Item(0)
System.Diagnostics.Process.Start(str)
' Response.Redirect(str)
End Sub
its getting filled in dataset..
but the file is not opening..
what shall i do???
thanks n regards,
kums
|
|
|
|
|
How to check the check boxes in the mailbox
by using the shift key.
|
|
|
|
|
anandbprem wrote: How to check the check boxes in the mailbox
by using the shift key.
Is that a question and then answer? Or is it something else. You might want to try and express that in a different way.
|
|
|
|
|
In datagridview when press any key then from that column select the Cell strats with that latter. How can i do tht the Grid is already bound.
|
|
|
|
|
Something like the following should get you started toward a solution.
private void yourDataGridView_KeyPress(object sender, KeyPressEventArgs e)
{
foreach (DataGridViewColumn column in yourDataGridView.Columns)
{
if (column.HeaderText.StartsWith(e.KeyChar.ToString()))
{
column.Selected = true;
break;
}
}
}
You will also need to pay attention to the EditMode property of the DataGridView , to stop the grid going into an edit state when the key is pressed. Read the documentation for EditMode for the options.
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.”
|
|
|
|
|
Hello,
When I call SDI winodw form from modal window and then again modal window form, from SDI window and when i close the last form the focus goes to first modal window istead of going to SDI window ... Can anybody tell me Why it happens ?
First window (Form1) ---> Call modal window on button click (Form2 f2=new Form2(); f2.showDialog();)
---> from Form2, Call SDI window (Form3 f3=new Form3(); f3.show()) -----> From Form3 call another modal window (Form4 f4=new Form4(); f4.showDialog();
When I close the fourth form the focus goes to Form2 instead of Form3 why It happens ? And it happens in case of compact framework C# ....
Regards
Rajesh
|
|
|
|
|
I am trying to create a licencing class library whereby an attribute is added to the AssemblyInfo.cs and when the assembly is loaded (not using Assembly.Load) validation is performed to see if the assembly has the attribute and then checks a licence key to ensure it can be run.
I thought the AppDomain.AssemblyLoad event might work, but after testing I am now assuming that only fires when you use Assembly.Load. I am a bit stuck as to whether this can be achieved and how.
I will eventually like to be able to do this validation at class level so that if someone tries instantiating an instance of the class, a licence is checked for access. One method is to use a proxy type mechanism like the Enterprise Library Injection Policy Application block, but ideally I would like it to fire is someone does the usual Foo f = new Foo(). The class level validation would ideally not have to be duplicated in every class (e.g. added to the constructors).
Any ideas on how to do this?
|
|
|
|
|
Hi,
I don't know about assembly events. However IMO you might be able to get what you want by adding code to the static constructor of the class you want to protect; in order to protect several classes, let their static constructors access the one class that takes care of licensing.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Thanks Luc.
I agree that I think my only option is going to be to add some code to the constructors of the classes I want to protect. I think I may also be able to use some interface that defines a method that adds a class type to some licence manager class.
Well off I go again for some more experimentation.
|
|
|
|