Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Birthday date problems

Birthday date problems

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasevisual-studiocomhelp
23 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jintal Patel

    your syntax is wrong near '" & Date.Today.Day ' for concat so correct syntax

    Jintal Patel

    M Offline
    M Offline
    matjame
    wrote on last edited by
    #14

    Conversion from string "Select * from Bithdays WHERE (DA" to type 'Long' is not valid. Error appears here str2 = "Select * from Bithdays WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day And "(DATEPART(day, BirthDate) = " & Date.Today.Month

    kagiso

    J 1 Reply Last reply
    0
    • M matjame

      Ok, I tried and loved it but the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method. But I tried to do this str2 = "Select * from Bithdays where WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day & AND "(DATEPART(day, BirthDate) = " & date.Today.Month But Im getting an error on "AND"

      kagiso

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #15

      matjame wrote:

      the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method.

      Yes, you can. The @mt and @dt values are parameters. Add two parameter objects to the command object, with the values for the month and day.

      Experience is the sum of all the mistakes you have done.

      1 Reply Last reply
      0
      • M matjame

        Conversion from string "Select * from Bithdays WHERE (DA" to type 'Long' is not valid. Error appears here str2 = "Select * from Bithdays WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day And "(DATEPART(day, BirthDate) = " & Date.Today.Month

        kagiso

        J Offline
        J Offline
        Jintal Patel
        wrote on last edited by
        #16

        hii sorry for let reply.. try this... str2 = " Select * from Bithdays WHERE (DATEPART(month, BirthDate)) ='" & Date.Today.Day &"' And (DATEPART(day, BirthDate) = '" & Date.Today.Month & "'"

        Jintal Patel

        M 1 Reply Last reply
        0
        • J Jintal Patel

          hii sorry for let reply.. try this... str2 = " Select * from Bithdays WHERE (DATEPART(month, BirthDate)) ='" & Date.Today.Day &"' And (DATEPART(day, BirthDate) = '" & Date.Today.Month & "'"

          Jintal Patel

          M Offline
          M Offline
          matjame
          wrote on last edited by
          #17

          Your solution has been morethan helpful.Now I can see the light, but the little problem I now encounter is that "No value given for one or more required parameters.".It was showing month as 14 which is today's day and 11 as the day which is the month.But after sorting the missing ")". I get this message on the GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind(). I checked the values how they correspond with the string, its fine and the date formate(yyyy/mm/dd) is fine.What cud be the problem now.

          kagiso

          J 1 Reply Last reply
          0
          • M matjame

            Your solution has been morethan helpful.Now I can see the light, but the little problem I now encounter is that "No value given for one or more required parameters.".It was showing month as 14 which is today's day and 11 as the day which is the month.But after sorting the missing ")". I get this message on the GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind(). I checked the values how they correspond with the string, its fine and the date formate(yyyy/mm/dd) is fine.What cud be the problem now.

            kagiso

            J Offline
            J Offline
            Jintal Patel
            wrote on last edited by
            #18

            please send me the total code or that function so i can understand your problem perfactly...

            Jintal Patel

            M 1 Reply Last reply
            0
            • J Jintal Patel

              please send me the total code or that function so i can understand your problem perfactly...

              Jintal Patel

              M Offline
              M Offline
              matjame
              wrote on last edited by
              #19

              Imports System.Data Imports System.Web.UI.Control Imports System.Web.UI.WebControls.WebControl Imports System.Web.UI.WebControls.LinkButton Imports System.Data.oledb Imports Microsoft.VisualBasic.ApplicationServices Imports Microsoft.VisualBasic.OpenShare Partial Class Birthdays Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim comx As New OleDbCommand Dim conx As New OleDbConnection Dim con As New OleDbConnection Dim str1 As String = "Provider = Microsoft.Jet.oledb.4.0; Data source =C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb" Dim cm As OleDbCommand Dim str2 As String con = New OleDbConnection(str1) con.Open() str2 = " Select * from Bithdays WHERE (DATEPART(Month, BirthDate)) ='" & Date.Today.Month & "' And (DATEPART(Day, BirthDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() If con.State = ConnectionState.Open Then con.Close() End If con.Open() End Sub Again, thank you very much for ur time and effort

              kagiso

              J 1 Reply Last reply
              0
              • M matjame

                Imports System.Data Imports System.Web.UI.Control Imports System.Web.UI.WebControls.WebControl Imports System.Web.UI.WebControls.LinkButton Imports System.Data.oledb Imports Microsoft.VisualBasic.ApplicationServices Imports Microsoft.VisualBasic.OpenShare Partial Class Birthdays Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim comx As New OleDbCommand Dim conx As New OleDbConnection Dim con As New OleDbConnection Dim str1 As String = "Provider = Microsoft.Jet.oledb.4.0; Data source =C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb" Dim cm As OleDbCommand Dim str2 As String con = New OleDbConnection(str1) con.Open() str2 = " Select * from Bithdays WHERE (DATEPART(Month, BirthDate)) ='" & Date.Today.Month & "' And (DATEPART(Day, BirthDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() If con.State = ConnectionState.Open Then con.Close() End If con.Open() End Sub Again, thank you very much for ur time and effort

                kagiso

                J Offline
                J Offline
                Jintal Patel
                wrote on last edited by
                #20

                hiii this will definately work just change ur str2 to belove str2 = "select * from Birthday WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind()

                Jintal Patel

                M 1 Reply Last reply
                0
                • J Jintal Patel

                  hiii this will definately work just change ur str2 to belove str2 = "select * from Birthday WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind()

                  Jintal Patel

                  M Offline
                  M Offline
                  matjame
                  wrote on last edited by
                  #21

                  You have no idea how much this means to me.It works like a charm. I wud buy you lunch, but ur there.Thanx a million. Damn, thank you very much.

                  kagiso

                  J 1 Reply Last reply
                  0
                  • S Sun Rays

                    matjame wrote:

                    Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement

                    Hi, What are you doing here ???????? write query as below... Select * from Bithdays where BirthDate LIKE '*/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() "'"

                    Thanks, Sun Rays

                    M Offline
                    M Offline
                    matjame
                    wrote on last edited by
                    #22

                    Howzit Sun Rays. Here is how the problem was solved. str2 = "select * from Bithdays WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() Thanx a million for your assistance

                    kagiso

                    1 Reply Last reply
                    0
                    • M matjame

                      You have no idea how much this means to me.It works like a charm. I wud buy you lunch, but ur there.Thanx a million. Damn, thank you very much.

                      kagiso

                      J Offline
                      J Offline
                      Jintal Patel
                      wrote on last edited by
                      #23

                      welcome

                      Jintal Patel

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups