Birthday date problems
-
your syntax is wrong near '" & Date.Today.Day ' for concat so correct syntax
Jintal Patel
-
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
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.
-
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
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
-
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
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
-
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
please send me the total code or that function so i can understand your problem perfactly...
Jintal Patel
-
please send me the total code or that function so i can understand your problem perfactly...
Jintal Patel
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
-
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
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
-
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
-
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
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
-
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
welcome
Jintal Patel