473,408 Members | 1,623 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,408 software developers and data experts.

how to insert date and time into sqldatabase

shivananda
hope every one doing well
i am new to vb.net when iam try to insert datetime into sqldatabase it is not inserting here is my code.
here unable to convert the datetime while inserting into database logs table

Expand|Select|Wrap|Line Numbers
  1.  con.open()
  2.  Dim cmd As New SqlCommand("INSERT INTO logs ([username],[date_time])VALUES(@username,@datetimepicker1)", con)
  3.                     With cmd.Parameters
  4.                         .AddWithValue("@username", username.Text)
  5.                         .AddWithValue("@date_time",datetimepicker1.text)
  6.                     End With
  7.                     cmd.ExecuteNonQuery()
  8.                     cmd.Dispose()
  9.                     con.Close()
May 17 '13 #1
3 1785
Rabbit
12,516 Expert Mod 8TB
Your parameters are named differently.
May 17 '13 #2
vijay6
158 100+
Hey shivananda, line number 5 in your code replace '@date_time' by '@datetimepicker1'.
May 17 '13 #3
hi vijay
its working
thank you for the suggestion
May 18 '13 #4

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...
2
by: JP SIngh | last post by:
Can someone please suggest the correct way to store the date & time in SQL Server? I want to store the date and time a record was created. What should the field type be in SQL Server? How can...
1
by: Monica Roman | last post by:
Hello, help please. I have a little macro that copies the date from a date/time field to a memo field, BUT instead of going to the memo field it finds the first date/time field and tries to copy...
1
by: seash | last post by:
H when i execute this query, my query is crashing throwing an exception "cant convert char datatype to datetime type format my query is "insert into mytable(mydate) values ('"+ varmydate+ "')...
2
by: Darhl Thomason | last post by:
I'm converting my Access 2003 VBA app. I have a number of date fields in my db that I want to use the date/time picker control with, but if there is no entry in my database, I want the date/time...
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 ...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
3
by: countryboy | last post by:
i am making a macro to sort a form at the end of my macro i want to put the form name that stays the same but i would like to insert the date and time, I can edit the macro with VB the line looks...
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)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.