how to retrieve a "date" data to the textbox? - Programmers Heaven

Howdy, Stranger!

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

Categories

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.