Results 1 to 3 of 3

Thread: Database and asp.net (VB)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    47

    Database and asp.net (VB)

    I was using the calendar feature whereby the user allows to clicks on the specific date.
    E.g: 13/3/2004 (Saturday). I would like to know whether asp.net has the function to call the Monday, Tuesday …. Sunday? If there is, could someone give sample of it as I do not know how to start. Thankz.

    If there isn’t a function to call the Monday, Tuesday…. Sunday, I’m thinking of using the database function :

    SET DATEFIRST 1
    SELECT DATEPART(dw, getDate()) AS 'Today'

    But the problem lie here. How to pass the selected date from the calendar to the database for checking whether it is which day?

    I am really thankful to those who help me out.

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    You can use .dayofweek with any date or datetime object such as
    VB Code:
    1. Dim tempDate As DateTime
    2.         tempDate = Now
    3.         If tempDate.DayOfWeek = DayOfWeek.Monday Then
    4.             'it's monday
    5.         ElseIf Now.DayOfWeek = DayOfWeek.Tuesday Then
    6.             'It's tuesday
    7.         Else
    8.             'it's not
    9.         End If

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    47
    Thank You Fishcake!!

    I have succed in retrieving information from the database. However i hope that i can pass the information to the label insead of datagrid. Can it be done by passing information from the database to the label?

    Here is how i pass to the datagrid:

    objCmd.commandtext = "spDateChecking"
    objCmd.CommandType = CommandType.StoredProcedure
    objCmd.connection = dbconn

    objParam = objCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int)
    objParam.Direction = ParameterDirection.ReturnValue
    objCmd.Parameters.Add("@SlotDateID", weekday_value)

    Dim myReader As OleDbDataReader
    myReader = objCmd.ExecuteReader

    If (myReader.HasRows) Then

    Dim result As Integer
    result = objCmd.Parameters("RETURN_VALUE").Value
    dgTicketPrice.DataSource = myReader
    dgTicketPrice.DataBind()

    End If

    'Close the connection object
    dbconn.Close()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width