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

vb - sql add record

jamesd0142
469 256MB
i have this:
Expand|Select|Wrap|Line Numbers
  1. Dim Date1 As String = Format$(Now)
  2.  
which gives the value like: "15/02/2008 13:29:41"

now im using this:
Expand|Select|Wrap|Line Numbers
  1. con.CommandText = "update users set [passwordchanged] = " & "'" & Date1 & "'" & " where [login] = " & "'" & txtlogchange.Text & "'"
  2.  
Date1 is being inserted into an sql table, field is smalldatetime(4).

I get the error:

The statement has been terminated.
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.

So how do iformat my date so it matches the smalldatetime(4) data type in sql server?

All other values in the table look like:
"15/02/2008 13:29:41"

So whats the problem?

James
Feb 15 '08 #1
3 1161
jamesd0142
469 256MB
fixed this now:

i needed to change the sql to:
Expand|Select|Wrap|Line Numbers
  1. con.CommandText = "update users set [password] = " & "'" & txtpasschange.Text & "'" & ", [passwordchanged] = " & _
  2. "convert(varchar(20), convert(smalldatetime, getdate()), 101)" & _
  3. " where [login] = " & "'" & txtlogchange.Text & "'"
  4.  
Line3 has the change^
Feb 15 '08 #2
debasisdas
8,127 Expert 4TB
You might need to format the date before processing .
Feb 15 '08 #3
jamesd0142
469 256MB
You might need to format the date before processing .
Yes once again debasisdas you where correct as you can see from the above post.

I had to convert it to smalldate before adding to the database (line3)

James
Feb 15 '08 #4

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

Similar topics

15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
8
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the...
2
by: Mark Reed | last post by:
Hi All, I have created a multi-user application at work which is working perfectly apart from a small problem which I believe to more a of a user issue (maybe some will set me straight on that...
3
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.