473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can i compare current date with the date stored in sql server Table in VB?

Hello Everyone please help me. I am new to VB and i want to know how to compare the current date with the date stored in the database table?
Jun 26 '14 #1
4 1636
twinnyfo
3,653 Expert Mod 2GB
Jayasai,

You need to provide more information for us to help you. Have you tried anything, yet? What types of errors are you getting? We would love to trouble shoot, but we don't have anything to go by.
Jun 26 '14 #2
Expand|Select|Wrap|Line Numbers
  1. Dim date1 As Date
  2.         Dim DOB As Date
  3.         Dim sql1 As String
  4.  
  5.         sql1 = "select DATE_OF_BIRTH from PERSON1 where  PERSON_ID=person.personId"
  6.         Dim command As OracleCommand = New OracleCommand(sql1)
  7.         'Dim datareader As OracleDataReader = command.ExecuteReader()
  8.         date1 = Convert.ToDateTime(Today)
  9.         DOB = command.ExecuteScalar()
  10.         If Date.Compare(date1, DOB) = 0 Then
  11.             Dim message As String = "!**Greetings***! Wow Today is Your's Birthday. Wish You A Happy Birthday! Wish you many more returns of the day. Have a lovely day"
  12.             Dim sb As New System.Text.StringBuilder()
  13.             sb.Append("<script type='text/javascript'>")
  14.             sb.Append("window.onload=function(){")
  15.             sb.Append("alert('")
  16.             sb.Append(message)
  17.             sb.Append(" ')};")
  18.             sb.Append("</script>")
  19.             ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", sb.ToString())
  20.         Else
  21.             Dim username As String
  22.             Dim sql2 As String
  23.             sql2 = "select First_Name from PERSON1 where convert.GETDATE()=DATE_OF_BIRTH "
  24.             Dim command1 As OracleCommand = New OracleCommand(sql2)
  25.             'Dim datareader As OracleDataReader = command.ExecuteReader()
  26.             username = command.ExecuteScalar()
  27.             Dim message1 As String = "!**Greetings***! Wow Today is " + username + " Birthday  and Wish him/her a Happy Birthday!"
  28.             Dim sb As New System.Text.StringBuilder()
  29.             sb.Append("<script type='text/javascript'>")
  30.             sb.Append("window.onload=function(){")
  31.             sb.Append("alert('")
  32.             sb.Append(message1)
  33.             sb.Append(" ')};")
  34.             sb.Append("</script>")
  35.             ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", "alert", sb.ToString())
  36.         End If
  37. I tried this code and i am getting error like this
  38.  
  39.  
  40.  Invalid operation. The connection is closed.
  41. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  42.  
  43. Exception Details: System.InvalidOperationException: Invalid operation. The connection is closed.
  44.  
  45. Source Error:
  46.  
  47.  
  48. Line 22:         'Dim datareader As OracleDataReader = command.ExecuteReader()
  49. Line 23:         date1 = Convert.ToDateTime(Today)
  50. Line 24:         DOB = command.ExecuteScalar()
  51. Line 25:         If Date.Compare(date1, DOB) = 0 Then
  52. Line 26:             Dim message As String = "!**Greetings***! Wow Today is Your's Birthday. Wish You A Happy Birthday! Wish you many more returns of the day. Have a lovely day"
Jun 27 '14 #3
twinnyfo,

Thank u for your response
Jun 27 '14 #4
twinnyfo
3,653 Expert Mod 2GB
Have you stepped through the code and validated that the connection is still open and that all variables evaluate to what you think they ought to be?
Jun 28 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
6
by: Phil Powell | last post by:
The date field I believe is of type datetime, but I'm sorry I have absolutely no idea how to put today's date into a datetime column using ASP and SQL Server. Folks, I'm a LINUX guy!!! This is a...
7
by: Vinnie Davidson | last post by:
Hello! I'm trying to get all records from my SQL Server Database with "DeadlineDate" = today (not today - 24 hours). All records has a field called "DeadlineDate", and the date is stored in...
0
by: Mark | last post by:
All, Excuse the re-post but I have found something which works for the UserID but not for the Password (see previous post below). The problem is I don't understand how it works and therefore...
3
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew =...
7
by: joeyej | last post by:
How do I compare today's date with this string (in my inc file) so that I can set an alert if date choice i.e. May 15, 2006 not at least greater than two days from current date? <option...
0
by: sourabhmca | last post by:
hi friend, I am want to insert date with time into sql server2000 using JSP.I hv 3 combo box for dd mm yyyy and 2 text box for hh and min ? and my table field type is smalldatetime.after that i ...
0
by: comp21 | last post by:
Hi, Now, I have retrieved or imported data from excel spreadsheet to vb6 application. Now I want to compare this part of data with the one already existing in mssql2000 server(table name being...
1
parshupooja
by: parshupooja | last post by:
Hi , I have asp.net page. I have few fields on page , I am inserting value into this fields which are getting saved into SQL server database. I have additional column into the table(SQL Server)...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.