Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to retrieve a "date" data to the textbox?

y1118y1118 Posts: 1Member
hi, does anybody know how to retrieve a date data from sql server to the textbox control in asp.net? i am suffering with this problem and hope that somebody can help, please :(

Comments

  • rajesh_baburajesh_babu Posts: 5Member
    : hi, does anybody know how to retrieve a date data from sql server to the textbox control in asp.net? i am suffering with this problem and hope that somebody can help, please :(
    :
    Hi..
    If U dont want any formatting and wanna just display the date from SQL Server to the textbox ,I hope the following code will do...
    Dim conStr, getDetails As String
    conStr= "server=localhost;database=pubs;uid=sa;password=;Trusted_Connection='yes'"
    getDetails = "Select hire_date from employee"
    Dim connection As New SqlConnection(conStr)
    connection.Open()
    Dim adapter As New SqlDataAdapter(Getdetails, connection)
    Dim dataset As New DataSet()
    Dim command As SqlCommand
    adapter.Fill(dataset)
    adapter.Dispose()
    connection.Close()
    txtDate.Text = dataset.Tables(0).Rows(0).Item(0)

    lemme know if u find any issue regarding this...
    regrads,
    rajesh...
  • fdittgenfdittgen Posts: 1Member
    little remark:
    To write Dates to DataBase: (e.g.)
    DateTime.Parse(txtDate.Text.Trim()) //prevents problems with format

    To show Data with DataBinding: (e.g.)
    '>

    Be careful to use the right culture. By using {0:d} you won't be surprised by the result.

    regards,

    Florian
    : : hi, does anybody know how to retrieve a date data from sql server to the textbox control in asp.net? i am suffering with this problem and hope that somebody can help, please :(
    : :
    : Hi..
    : If U dont want any formatting and wanna just display the date from SQL Server to the textbox ,I hope the following code will do...
    : Dim conStr, getDetails As String
    : conStr= "server=localhost;database=pubs;uid=sa;password=;Trusted_Connection='yes'"
    : getDetails = "Select hire_date from employee"
    : Dim connection As New SqlConnection(conStr)
    : connection.Open()
    : Dim adapter As New SqlDataAdapter(Getdetails, connection)
    : Dim dataset As New DataSet()
    : Dim command As SqlCommand
    : adapter.Fill(dataset)
    : adapter.Dispose()
    : connection.Close()
    : txtDate.Text = dataset.Tables(0).Rows(0).Item(0)
    :
    : lemme know if u find any issue regarding this...
    : regrads,
    : rajesh...
    :

Sign In or Register to comment.