473,413 Members | 2,051 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,413 software developers and data experts.

Insert date value into Access DB

I am really pissed with this date problem. please help me out.....

Expand|Select|Wrap|Line Numbers
  1. Public rs As New ADODB.Recordset
  2. Private Sub Command1_Click()
  3.  
  4. Call connection
  5. Set rs = New ADODB.Recordset
  6. rs.Open "INSERT INTO DateTry(Date,Name) VALUES('" & Text1.Text & "','" & Text2.Text & "')", con, 3, 3
  7. con.Close
  8.  
  9. End Sub
Plzzzzzzzzzzzzz Help!!!!!!!!!!!
Feb 15 '08 #1
6 2274
It gives SYNTAX ERROR IN INSERT INTO STATEMENT error.....
Feb 15 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

What is your Database....?

REgards
Veena
Feb 15 '08 #3
debasisdas
8,127 Expert 4TB
Why you are using INSERT INTO while opening a record set ?
Feb 15 '08 #4
lotus18
866 512MB
Hi

You cannot make Date as your field name. And if you want to insert date, it should be enclosed it with #.
Expand|Select|Wrap|Line Numbers
  1. Public rs As New ADODB.Recordset
  2. Private Sub Command1_Click()
  3.  
  4. Call connection
  5. Set rs = New ADODB.Recordset
  6. rs.Open "INSERT INTO DateTry ([MyDate],[Name]) VALUES(#" & Text1.Text & "#,'" & Text2.Text & "')", con, 3, 3
  7. con.Close
  8.  
Rey Sean
.
Feb 15 '08 #5
I am using access....
Feb 18 '08 #6
Killer42
8,435 Expert 8TB
Possibly you can use Date as a field name, I'm not sure. But it's a really bad idea.

As lotus18 pointed out, you need to use # delimiters around the date value in your SQL string. What he didn't mention is that the value must be in American format - that is, mm/dd/yyyy. You might be able to get away with using a different format, as long as there's no way the day and month can be confused - for example #01-Feb-2008#. If you try to use dd/mm/yyyy format, it will only work when the day is higher than 12 so Access can't mix up the day and month.

I think debasisdas also raised a valid concern.
Feb 18 '08 #7

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

Similar topics

3
by: jason | last post by:
I need to deposit and empty dummy value into a date/time field within Access using INSERT. However, I pick up a data type error if I attempt to insert a NULL value for this particular date time...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
1
by: glenn | last post by:
Hi folks, I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL...
5
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
4
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I...
7
by: ammmmmu | last post by:
Hi all, I am using VB 5.0 and msaccess as a database, I am reading the data from logfiles and inserting it in db, its not throwing any error, but after excecution I not find any records in table...
1
by: billa856 | last post by:
Hi, I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date. I am using "" to insert Null in that column(ShipDate)...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.