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

I give up with this. Need help

Hi,
I have a table with a field that should store date and time. The table
column data type is datetime.

I am trying

Dim dt as datetime

helper.exeutenonquery(connection,storedprocedure," testproc",new
sqlparameter("@date",dbtype.datetime,dt.now.tostri ng()))

I get the error

"Cast form string "11/1/2005 10:43:24 AM" to typr integer is not valid.

Please. What's the recommended way in passing date or datetime to sql server
and waht is the recommended column datatype in sql server. So far I believe
datetime is recommended for sql server but waht if I need to store the date
as 20051101?

Please assist.
Nov 1 '05 #1
2 1271
I think you will find that these columns are really stored as strings.
I believe you need to convert to an integer type before you can use it
as you've defined it.

I use groups to define the numerics and then use them that way.

HTH,

Chris wrote:
Hi,
I have a table with a field that should store date and time. The table
column data type is datetime.

I am trying

Dim dt as datetime

helper.exeutenonquery(connection,storedprocedure," testproc",new
sqlparameter("@date",dbtype.datetime,dt.now.tostri ng()))

I get the error

"Cast form string "11/1/2005 10:43:24 AM" to typr integer is not valid.

Please. What's the recommended way in passing date or datetime to sql server
and waht is the recommended column datatype in sql server. So far I believe
datetime is recommended for sql server but waht if I need to store the date
as 20051101?

Please assist.


--
Russ Eggen
www.radfusion.com
Nov 1 '05 #2
Chris wrote:
Hi,
I have a table with a field that should store date and time. The table
column data type is datetime.
Then why are you converting it to a string when you pass it in?
Dim dt as datetime

helper.exeutenonquery(connection,storedprocedure," testproc",new
sqlparameter("@date",dbtype.datetime,dt.now.tostri ng()))


Here, you call the "tostring" method so you are passing in a string and
not a datetime. Secondly, "Now" is a shared method of the DateTime
class. You should not call it on an instance of the class. VB allows
this, C# does not. Have you tried this:

helper.exeutenonquery(connection,storedprocedure," testproc",new
sqlparameter("@date",dbtype.datetime,DateTime.Now) )

-- OR (using your variable) --

Dim dt as datetime

dt = DateTime.Now

helper.exeutenonquery(connection,storedprocedure," testproc",new
sqlparameter("@date",dbtype.datetime, dt))

Nov 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mimages | last post by:
I can't figure this out. There are too many differences between my installation of osCommerce and what I read on these forums, and in the contributions' readme files. I have either lost my logical...
2
by: live | last post by:
Can some one give me help? I need some information about: How can I compile php project on a executable and run it on CGI. Thanks
10
by: techy techno | last post by:
Hiii Hello.. I just wanted to know if anyone can tell me how can I give my website visitors the feature of "FRIENDLY PRINTING" through IE. I would definitely like to give a feature like...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
18
by: free2cric | last post by:
Hi, I attanded an interview on C++ Question asked were and my answers to them.. 1. In a CPP program what does memory leak occure? -- i said.. In a constructor , the pointer variables were...
2
by: Rachel Curran | last post by:
Please can anybody help me with the following: I have two separate excel spreadsheets that I have imported into access, each sheet holds the same fields. Both spreadsheets hold all information...
6
by: Luca | last post by:
Hi everyone, I'm super-newbie here... so thanx in advance for any help I shoud give a "value" to an DIV's ID that change following the name of the directory where the file is. For example the...
1
by: Ellen12c | last post by:
On the last post I asked about a code to make a vertical scroll bar and ends up I didn't need one. I was told by a big group of people on this forum that I needed to do away with all the flash and...
11
by: aslamhenry | last post by:
hem anyone can give me an idea on how to saparated digits using looping example please key in any 5 digits number : 56789 and the ouput is 5678 9 5678 9
7
by: alvinstraight38 | last post by:
Hey guys, I'm pretty new to SQL configuration, and I need to give EXECUTE persmissions for one of the SQL user roles. I am running SQL 2005 Management Studio Express - free version. I found...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.