|
Hi guys, I just need a little help in retrieving date value from database.
The format of date in date field is "2015-07-03 00:00:00.000"
but when I retrieve it the format automatically change into "07/03/2015 12:00:00"
How can I retrieve the date value as is? I'm using vb.net. Thanks in advance for the help.
|
|
|
|
|
The date value stored in database does NOT depend on the date format used in your system.
So the text "07/03/2015 12:00:00" is not what you "retrieve" but it is what displayed is.
|
|
|
|
|
Then how can I retrieve the same date format value in my database upon retrieval Sir? I am using "Select * From Tablename" query and Tablename can be change depends on what table was selected by user.
|
|
|
|
|
You don't. The date is formatted not on retrieval from the database but on display to the user in your UI.
|
|
|
|
|
Since we cannot see your code it is impossible to guess what is happening. But it could be that you are not formatting the text in the correct way.
|
|
|
|
|
Here is my code:
Dim xTable As New DataTable
Using conn As New SqlConnection(ConnString1.Text)
conn.Open()
Dim TableName As String = DgvTable1.CurrentRow.Cells(0).Value
Dim command As New SqlCommand("Select * From " & TableName, conn)
Dim da As New SqlDataAdapter
da.SelectCommand = command
da.Fill(xTable)
End Using
|
|
|
|
|
Where is the code that displays the date?
|
|
|
|
|
There is no code on displaying the date, I just saw the format of the retrieved date value during Break (F9).
|
|
|
|
|
Sorry, but that has no bearing. The debugger will display dates in the default format.
|
|
|
|
|
Again, date values only get a format when displayed to the user. In this case, the user is you and the UI is the visualizer in the debugger. The visualizer will use the date format specification for your country settings in Windows.
Dates in the database do not have a format.
|
|
|
|
|
Hi
I have working code that shows a dialog box to pick an Outlook email folder.
I always choose the same folder - "\\Shared\Updates" - can someone tell me how to assign the correct value to olfolder please?
Your assistance greatly appreciated.
Dim olfolder As Outlook.MAPIFolder
olfolder = objOL.GetNamespace("MAPI").PickFolder
|
|
|
|
|
Not entirely sure but seems you are looking for how to assign the folders based on need. Following two links would help:
Folder.Items property (Outlook) | Microsoft Docs
OlDefaultFolders enumeration (Outlook) | Microsoft Docs
Based on the folder needed, you can set/assign and use:
Sub ContactDateCheck()
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNamespace = Application.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items
Set myItems = myContacts.Restrict("[LastModificationTime] > '01/1/2003'")
For Each myItem In myItems
If (myItem.Class = olContact) Then
MsgBox myItem.FullName & ": " & myItem.LastModificationTime
End If
Next
End Sub
|
|
|
|
|
Not quite what I am after.
I know in advance which subfolder I need - it's always the same one, so having to select it from a list of all folders and subfolders seems silly.
I need a way of specifying one subfolder without
olfolder = objOL.GetNamespace("MAPI").PickFolder
|
|
|
|
|
And I solved it - for any one who is interested here is the solution
<pre>Dim olfolder As Outlook.MAPIFolder
olfolder = objNS.Folders("Membership").Folders("Updates")
myItems = olfolder.Items
Thanks for help
|
|
|
|
|
DEAR ALL,
I NEED A CODE FOR MANAGE STOCK BALANCE REPORT
EXAMPLE:
DATE ITEM CODE ITEM NAME QTY STOCK BALANCE
01/09/2020 1001 ITEM-1 100 100
02/09/2020 1001 ITEM-1 20 120
02/09/2020 1002 ITEM-2 110 110
03/09/2020 1001 ITEM-1 20 140
THIS TYPE OF MY DATATABLE IN MICROSOFT ACCESS
SO I WANT TO AUTO CALCULATE STOCK BALANCE LIKE ITEM-1 PURCHASE IN DIFFERENT DATES AND CALCULATE STOCK BALANCE OF ITEM-1
AND IN SAME TABLE I MANAGE OTHER ITEMS BALANCE ALSO
SO I WANT CODING ITEMWISE
THANKS
|
|
|
|
|
Sorry, this site does not provide code to order; try freelancer.com.
|
|
|
|
|
THANKS FOR YOUR SUGGESTION GOOD BYE
|
|
|
|
|
Typing everything is all CAPS is seen as screaming whatever you're saying. Don't do it.
The only code you're going to get is the code you write. Nobody is going to do your work for you.
|
|
|
|
|
Are you ready? Here's the code: G-53
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I require to assign an Action to a method.
I can do this in C# without problem.
But when I port the C# code to VB.NET I fail at one line.
My company has a VB.NET application where we require this solution.
I have created a small and reproducible solution regarding this in both a C# and VB.
Of course this is not the real solution I have, but the problem is same.
C# code
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var foo = new Foo();
foo.Bar = Qux;
foo.Baz();
}
static void Qux()
{
Console.WriteLine(nameof(Qux));
}
}
class Foo
{
public Action Bar { get; set; }
public void Baz()
{
Bar();
}
}
} VB.NET code
Module Module1
Sub Main()
Dim foo As Foo = New Foo()
foo.Bar = Qux()
foo.Baz()
End Sub
Sub Qux()
Console.WriteLine(NameOf(Qux))
End Sub
Class Foo
Private b As Action
Public Property Bar() As Action
Get
Return b
End Get
Set(ByVal value As Action)
b = value
End Set
End Property
Public Sub Baz()
b()
End Sub
End Class
End Module The compile error message: Expression does not produce a value
VB.NET is not my primary language and I'm sure I have made some very basic mistake.
I don't like to ask for a solution, but I cannot find the correct way to do this.
Please provide me with the correct solution to fix this.
|
|
|
|
|
In your VB.NET code, you're calling the Qux method, and attempting to store the return value in an Action . But the method doesn't return a value, so there's nothing to store, and you get a compiler error.
You need to use the AddressOf operator to create a delegate pointing to the required method:
foo.Bar = AddressOf Qux AddressOf Operator - Visual Basic | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks!
It I tried the AddressOf earlier, but beeing used to C# I added parentheses as well: AddressOf(Baz) .
Of course that doesn't work
|
|
|
|
|
Strange, it was working, then it stopped.
When I add DESC, the sort gets scrambled. I checked my RDLC for a sort somewhere, but it's a straight feed.
I tried Desc, Asc works
Dim dVa As New DataView(tableInventoryItems)
Select Case pSorting
Case InventoryEriReportDialog.Type_EriReportR2_Sort.ITEM
dVa.Sort = "FITEMNO"
Case InventoryEriReportDialog.Type_EriReportR2_Sort.ATD3YA
dVa.Sort = "FATD3Y_A DESC"
Case InventoryEriReportDialog.Type_EriReportR2_Sort.PTDA
dVa.Sort = "FPTD0_A DESC"
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
According to the documentation[^], it should work. What does the data look like?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The column is a decimal. It must another sort call that I didn't see later on in the chain. I'll keep looking.
125.63
25.39
512.69
12.58
14.59
789.00
If I use Asc or nothing
12.58
12.59
14.59
125.63
512.69
789.00
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|