Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2005, 01:46 AM
Authorized User
 
Join Date: Feb 2005
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ashokparchuri Send a message via Yahoo to ashokparchuri
Default passing date time values to sql

hello,

i am using the following commands.

dim dt as sqlparameter("@date",sqldbtype.datetime)
dt.value=txtdt.date
dt.direction=parameterdirection.input
cmd.parameters.add(dt)

i am getting a data from textbox and i am passing the values to sql database.in the sqldatabase parameter"@date" is declared as "datatime". when i am working with this code i am getting an error "http:500":unable to run scripts.

 so i thought i am taking a string value from textbox and i have to convert it into date value.am i correct?if yes please tell me how to convert string values to datetime values.

   if no please tell me what i have to do.

thanks in advance-Ashok Parchuri
 
Old March 12th, 2005, 08:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Just because you're entering a date in the textbox, doesn't mean the textbox gets a Date property. You need to use its Text property instead:

dt.value = txtdt.Text
dt.direction = parameterdirection.input

You can also cast the text to a valid date using methods on the Convert class.

Alternatively, you could use a Calendar control....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 14th, 2005, 09:38 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I am using vb.net in windows xp home edition. when i wish to create a new asp.net web application from vb.net, the error shows "web access failed from root directory wwwroot"

Please help me how to create a asp.net web application.

Thanx.

M.Jaffar

 
Old March 14th, 2005, 12:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What exactly does this have to do with passing date time values to sql ?

I think you're better off posting a new thread in a more appropriate forum like http://p2p.wrox.com/forum.asp?FORUM_ID=97 or http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/

Cheers,

Imar
 
Old March 15th, 2005, 01:47 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

ashokparchuri,

personally I use DateTime instead of a string for working on date column,it could be better!

for casting a text to a valid date use Parse method of DateTime and handle the exceptions.

_____________
Mehdi.
software student.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Input Date Parameter values preethig Crystal Reports 0 February 28th, 2008 08:39 AM
sql date/time keyvanjan Classic ASP Basics 5 July 22nd, 2006 03:20 PM
DTS package - passing values at run time kkrish SQL Server 2000 1 June 20th, 2006 04:56 PM
Passing Date, String values in ASP Function. rupen Classic ASP Basics 2 July 6th, 2005 09:42 PM
Date Time - From & To Passing shrishankaraan Crystal Reports 0 May 26th, 2004 10:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.