|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

July 5th, 2009, 04:47 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
change string to datetime in ado.net
hi everyone
I have a number of tables (8) that i need to insert data into at almost the same time(thats how my user will see it). I have a form with tabpages they use to insert data into the tables.
I am using an insert store procedure to aid with all this. Now my problem is that i have a few datetimepickers my user uses to insert dates into the respective attributes,their data type is date. when i try to save the data i get the following error.
'Failed to convert parameter value from string to datetime'
I have also attached a sample of one of the datetimepickers i am using. Please help me sort this out.An example will be appreciated.
saveCommand.Parameters.AddWithValue("A_BOOKDATE", abookdatePicker1.Text).DbType = DbType.DateTime
Many Thanks in advance
Last edited by slake : July 5th, 2009 at 04:48 PM.
Reason: spelling mistake
|

July 5th, 2009, 06:50 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 151
Thanks: 2
Thanked 32 Times in 32 Posts
|
|
Hi Slake,
Have you tried changing the code to use abookdatePicker1.Value instead, which gets the value as an actual DateTime?
There isn't always a direct link between what format a .NET control displays a date in and what SQL Server or another database expects it to be passed in as, so it is always best to pass an actual DateTime to the Parameter.Add methods whenever possible.
HTH
Phil
|
|
The Following User Says Thank You to philip_cole For This Useful Post:
|
|

July 7th, 2009, 04:54 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Values duplicated in database
hi
i got it to work but im now faced with a new problem.
I have a procedure that handles all my inserts into the system. I make these inserts into the database using a Vb form. Now my problem is that when i click the save button the values a duplicated in the database. I cannot quite understand why thsi is the case.
Do you by any chance know why this so? Please advise. Look forward to hearing from you.
Kind Regards
Slake
|

July 8th, 2009, 05:01 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 211
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
Slake:
I just had a thought or two on your duplication of records, but you will have to read how to translate to VB.NET-ese. Check on the following: - The state of the Cache especially after you have process that form page;
- Review how the rows are processed automatically. I can't remember the code u submitted in an earlier thread.
Just a thought or two.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
|
|
The Following User Says Thank You to peace95 For This Useful Post:
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |