hi,
can u plz tell me how to insert date in to msaccess
i have
text1.text=date
what is the sql statement for inserting
insert into table_name (datecolumn) values ('"+text1.text+"')
this is showing error... plz check with this.. urgent...
hi,
can u plz tell me how to insert date in to msaccess
i have
text1.text=date
what is the sql statement for inserting
insert into table_name (datecolumn) values ('"+text1.text+"')
this is showing error... plz check with this.. urgent...
The errors here come from two separate issues: the code is building SQL by concatenating a textbox string, and the Access column is a Date/Time type while the textbox supplies a string. correctly flagged the type mismatch; and were pointing toward using a proper date value and Access-specific handling. The safest, most robust fix is to stop concatenating text and pass a typed Date/DateTime value to the database using a parameterized command.
A minimal VB.NET pattern you can apply (validate the input, convert to a DateTime, then pass it as a typed parameter):
Dim dt As DateTime
If Not DateTime.TryParse(text1.Text, dt) Then
' handle invalid date input
Else
Using conn As New OleDb.OleDbConnection(connString)
Using cmd As New OleDb.OleDbCommand("INSERT INTO table_name (datecolumn) VALUES (?)", conn)
cmd.Parameters.Add(New OleDb.OleDbParameter("pDate", OleDbType.Date)).Value = dt
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
End If Practical troubleshooting notes tied to the thread: an UPDATE must include a SET clause (that was the syntax mistake in the retrieval attempt). When comparing dates, remember Access stores time-of-day too — exact equality often fails if the time differs. To find rows for a calendar day, use a range (start-of-day >= parameter AND < next-day) or store/compare only the date portion. Always validate user input (IsDate or TryParse) and prefer parameters to avoid locale-format issues and SQL injection.
Checklist: validate the textbox as a date, pass a typed parameter (not a quoted string), correct your UPDATE syntax to include SET, and account for time components when matching dates.
Jump to Post— jbennet 1,618thats because text1.text is a string and t_Date is probably something else (date/time?)
hi!
just try with this command.
text.text=now()
hi.. thanq...
while retriving itz showing the prob...
text1.text=now()
update table_name where t_date='"+text1.text+"'
here itz showing data mismatch
thats because text1.text is a string and t_Date is probably something else (date/time?)
Hi,
u have to use this synatx in AccessSQl :
insert into table_name (datecolumn) values (#" & text1.text & "#) or
insert into table_name (datecolumn) values (Cdate(" & text1.text & ")) Regards
Veena
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.