 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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
|
|
|
|

March 14th, 2006, 11:09 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
IConvertible Error
Hi All,
I get this error in my page : Object must implement IConvertible.
Below is my code, can somebody point out what is the error about? I really have no idea why have this error.
Code:
'Add PackageBooking info in PackageBooking table in database
Private Sub RecordBooking(ByVal PackageID As String)
Dim a As New Common
Dim con As New SqlConnection
con = a.GetConnect()
Dim str As String
Dim SqlDataAdapter1 As New SqlDataAdapter
Try
str = "INSERT INTO PackageBooking(PackageID, TotalAmt, Username, CCNumber, CCType, CCValidationNumber, CCHolderName, BookDate, BookTime, CCExpMonth, CCExpYear) Values " _
& " (@PackageID, @TotalAmt, @Username, @CCNumber, @CCType, @CCValidationNumber, @CCHolderName, @BookDate, @BookTime, @CCExpMonth, @CCExpYear)"
Dim InsCom As New SqlCommand(str, con)
SqlDataAdapter1.InsertCommand = InsCom
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@PackageID", SqlDbType.Int, 4))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@TotalAmt", SqlDbType.Money, 8))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@Username", SqlDbType.VarChar, 10))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCNumber", SqlDbType.VarChar, 50))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCType", SqlDbType.VarChar, 50))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCValidationNumber", SqlDbType.VarChar, 50))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCHolderName", SqlDbType.VarChar, 50))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@BookDate", SqlDbType.DateTime, 8))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@BookTime", SqlDbType.DateTime, 8))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCExpMonth", SqlDbType.VarChar, 8))
SqlDataAdapter1.InsertCommand.Parameters.Add(New _
SqlParameter("@CCExpYear", SqlDbType.DateTime, 8))
SqlDataAdapter1.InsertCommand.Parameters("@PackageID").Value = lblPackage_ID.Text
SqlDataAdapter1.InsertCommand.Parameters("@TotalAmt").Value = txtTotalAmt.Text
SqlDataAdapter1.InsertCommand.Parameters("@Username").Value = lblUsername.Text
SqlDataAdapter1.InsertCommand.Parameters("@CCNumber").Value = txtCCNumber.Text
SqlDataAdapter1.InsertCommand.Parameters("@CCType").Value = ddlCCType.SelectedValue
SqlDataAdapter1.InsertCommand.Parameters("@CCValidationNumber").Value = txtCCValNumber.Text
SqlDataAdapter1.InsertCommand.Parameters("@CCHolderName").Value = txtCCHolderName.Text
SqlDataAdapter1.InsertCommand.Parameters("@BookDate").Value = DateTime.Today.Date
SqlDataAdapter1.InsertCommand.Parameters("@BookTime").Value = DateTime.Today.TimeOfDay
SqlDataAdapter1.InsertCommand.Parameters("@CCExpMonth").Value = ddlCCExpMonth.SelectedValue
SqlDataAdapter1.InsertCommand.Parameters("@CCExpYear").Value = txtCCExpYear.Text
con.Open()
SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
Catch ex As Exception
Dim b As String
b = ex.Message
End Try
con.Close()
RecordNumberBooked(lblPackage_ID.Text)
tblBookingSuccess.Visible = True
End Sub
Thanks.
Ai Ling
|
|

March 15th, 2006, 12:58 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
What line is the error on?
|
|

March 15th, 2006, 05:06 AM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi,
i found that error in the Catch part, b = ex.Message
Thanks.
Ai Ling
|
|

March 15th, 2006, 10:50 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
That's not helpful. You need to debug or use a different exception type to get more info.
|
|

March 15th, 2006, 09:26 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I am not sure whether the error lies with this line of code:
SqlDataAdapter1.InsertCommand.Parameters("@BookTim e").Value = DateTime.Today.TimeOfDay
It is because when I debug, and point to this line, it didn't show the value of the current time.
What other exception type that I can use to trace the error? Thanks a lot.
Ai Ling
|
|

March 16th, 2006, 12:18 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
try to use an exception type of sqlexception and see what happens.
|
|
 |