By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

####Datatype error

P: n/a
Hello

I am trying to push the data from my datatable to my database. However i keep getting an error stating

Error converting data type char to datetime

Here is my code
daClient.InsertCommand.Parameters.Add("@RoomID", SqlDbType.Char, 5, "RoomID"
daClient.InsertCommand.Parameters.Add("@RoomDt", SqlDbType.Char, 50, "RoomDt"
daClient.InsertCommand.Parameters.Add("@Req_Sessio n", SqlDbType.Char, 1, Req_Session"
daClient.InsertCommand.Parameters.Add("@Req_Layout ", SqlDbType.Char,
50, "Req_Layout"
daClient.InsertCommand.Parameters.Add("@Guests", SqlDbType.Char, 4, "No_Of_Guests"

The RoomDt column is stored as a datetime column in my databas
and the No_Of_Guests column is stored as an Int(4) column in my database

when i tried to change the RoomDt datatype above to:
daClient.InsertCommand.Parameters.Add("@RoomDt", DateTime, "RoomDt"

i still get an error message that says
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dl
Additional information: Cast from string "RoomDt" to type 'Integer' is not valid

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.