Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !!


I have Enter date in Text box on my webpage in formate of dd/MM/yy.for Example -- 24/08/12

But When page redirects it displays date as - yy/MM/dd for Exp- 12/08/24

Any solution for this problem ??


My coding is below



Quote:
Imports System.Data.OleDb.OleDbCommand
Imports System.Data.OleDb.OleDbConnection
Imports System.Data.OleDb.OleDbDataReader
Imports System.Data.OleDb
Imports System
Partial Class Admin
Inherits System.Web.UI.Page
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim datastring As String
Dim cmd1 As OleDbCommand
Dim cmdstr As String
Dim FileNameStr As String
Dim FileStore As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strdate As String

If IsPostBack = False Then
If (Session("UserName")) = "" Then
Response.Redirect("index.aspx")
Else
Response.ClearHeaders()
Response.AddHeader("Cache-Control", "No-cache,no-store,max-age=0, must-revalidate")
Response.AddHeader("Pragma", "no-cache")
End If
End If



If FileUpload1.HasFile = True Then

strdate = (Date.Now).ToString("mmddyy")
Session.Item("strfile") = strdate

FileNameStr = TxtPdate.Text

Dim Ext As String = System.IO.Path.GetExtension(FileUpload1.FileName)

FileUpload1.SaveAs(Request.PhysicalApplicationPath & "Uploaded Files\" & strdate & Ext)


Lbl1.Text = "File Successfully Uploaded"

Else

'Lbl2.Text = "No Uploaded File"

End If




End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click



cn = New OleDbConnection("Provider= Microsoft.Jet.Oledb.4.0;Data source =" & Server.MapPath("DEO.mdb"))
cn.Open()
cmd = New OleDbCommand("select select format(ParipatraDate,'dd/MM/yy')As GRDate,Subject,FileName from Paripatra", cn)


Dim Ext As String = System.IO.Path.GetExtension(FileUpload1.FileName)
cmdstr = "Insert into Paripatra (ParipatraDate,Subject,FileName)values(#" & TxtPdate.Text & "#,'" & TxtParipatra.Text & "','" & Session.Item("strfile") & Ext & "')"

cmd.CommandText = cmdstr
cmd.ExecuteNonQuery()



End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Session.Clear()
Response.Redirect("index.aspx")

End Sub
End Class
Posted
Updated 6-Mar-13 20:40pm
v2

1 solution

Txtbx1.Text=datatable.rows[0]["date"].tostring("dd MMM yyyy");
 
Share this answer
 
Comments
Md Jamaluddin Saiyed 7-Mar-13 12:05pm    
Thanks for Solution Avik but I dont understand in above code where I can use this code ?
Avik Ghosh22 8-Mar-13 0:12am    
I gave an example just... i have no idea about VB ... in c# ,this is a process to change date format ...
Md Jamaluddin Saiyed 9-Mar-13 9:54am    
I want to display whole data in database not particular one

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900