Solved

Cant Insert date value in access database

Posted on 2004-09-27
5
138 Views
Last Modified: 2010-04-06
Here's my code:
 
  iTime_Slot = (myDataReader.Item("Time_Slot"))
  iDate = (myDataReader.Item( "Date"))      

               DBInsert.CommandText = "Insert Into Attendees " _
               & "(First_Name, Last_Name, Company, Address, City, State, Zip, Phone, Domain_Name, Email, Date, Time_Slot)" _
               & "values ( '" & First_Name & "','" & Last_Name & "','" & Company & "','" & Address1 & "','" & City & "','" & State & "','" & Zip & "','" & TotalPhone & "','" &
               Website & "','" & Email & "','" & zDate & "','" &  iTime_Slot & "' )"

Suffice it to say, the date & time selected by user are successfully passed to the variables iTime_Slot & iDate. Moreover, in SQL string I have no problem repassing the iTime_Slot time to the 2nd table. I cannot seem to pass date though. I am very frustrated as the values I am trying to pass to the second table, while the user makes his choice, are nonetheless coming from fields in the first table. In borth tables, date ad time have the same data type, i.e. Date/Time. So naturally, I am ervy frustrated.

Does anyone have the solution of passing the date variable, selected by user from table 1 into the date field of table 2?
0
Comment
Question by:ednugentcpa
5 Comments
 

Author Comment

by:ednugentcpa
ID: 12164801
Nevermind, I solved the problem.

For those who run into this situation, don't name your database field "Date" as that is a predefined term in ASP. I changed field to Date_Slot and everything worked fine.
0
 
LVL 2

Expert Comment

by:vdhant
ID: 12165797
you can give the points to me if you want ;)
ant
0
 
LVL 3

Expert Comment

by:Jankit141180
ID: 12216052
Before i submit , i wish to let u let u know a require thing to do  which i have understood from your problem statment.

YOu need to set the datatype for your database fields named 'Date' to 'Date/Time' and make its format to 'Medium Date'.

Then put '#' as prefix to your date variable. like ........

I have made a little change in the insert script mentioned by you.

 DBInsert.CommandText = "Insert Into Attendees " _
               & "(First_Name, Last_Name, Company, Address, City, State, Zip, Phone, Domain_Name, Email, Date, Time_Slot)" _
               & "values ( '" & First_Name & "','" & Last_Name & "','" & Company & "','" & Address1 & "','" & City & "','" & State & "','" & Zip & "','" & TotalPhone & "','" &
               Website & "','" & Email & "',#" & zDate & "#,'" &  iTime_Slot & "' )"


Still u were not able to solve the problem then put replace 'Date' (your database field) with '[Date]'.

You will definitely find a solution.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12471972
PAQed, with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question