Trouble adding fields to database.

cfisher440

Well-known member
Joined
Oct 11, 2005
Messages
73
Programming Experience
1-3
I am having trouble adding data to my database.
I am in the middle of developing a program.

VB.NET:
Dim totHDRec, totHDAnsd, TotHDAbd, HDxfer, fHDrec As Int32
Dim totHDTalk, totAvgHDAnsd, totHDWork As String
'Assume all the variables above have data in them
 
AddDatabase(totHDRec, totHDAnsd, TotHDAbd, HDxfer, fHDrec, totHDTalk, totAvgHDAnsd, totHDWork)
 
'This is the function that adds the data to the database.
'But it will only put the int32 values in the database.
Public Sub AddDatabase(ByVal a1 As Int32, ByVal a2 As Int32, ByVal a3 As Int32, ByVal a4 As Int32, _
    ByVal a5 As Int32, ByVal a6 As String, ByVal a7 As String, ByVal a8 As String)
        Dim newRow As DataRow = DsVRUSys1.ACDSysSum.NewRow
        newRow("TotalRecieved") = a1
        newRow("TotalAnswered") = a2
        newRow("TotalAbandoned") = a3
        newRow("Transfered") = a4
        newRow("FirstRecord") = a5
        newRow("AvgTotTalk") = a6
        newRow("AvgTotAnsd") = a7
        newRow("AvgWork") = a8
        DsVRUSys1.ACDSysSum.Rows.Add(newRow)
        daVRUSys.Update(DsVRUSys1, "ACDSysSum")
    End Sub
'The Int32 values are added to the database, the strings are not.
'Recieve the following error message.

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: System.FormatException: Input string was not in a correct format.
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int16.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Convert.ToInt16(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToInt16(IFormatProvider provider)
at System.Convert.ToInt16(Object value)
at System.Data.Common.Int16Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <05:49> in AvgTotTalk Column. Expected type is Int16.

When I convert the values to the last values in the function to datetime I recieve this error message.

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: System.FormatException: Input string was not in a correct format.
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int16.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Convert.ToInt16(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToInt16(IFormatProvider provider)
at System.Convert.ToInt16(Object value)
at System.Data.Common.Int16Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <5:49:00 AM> in AvgTotTalk Column. Expected type is Int16.

Part of the problem is that the data is a time value (ex. 10:56 or 15:32).
I am reading it in as a string value and trying to add it to the database, but no dice. I have tried converting the value to a datetime, but when it does, it doesn't stay in the HH:MM (hour/minute) format, vb.net makes it "HH:MM:SS AM (or PM)".
When I make it a string format VB.net will make leave it in the HH:MM format but it is in quotes (unlike the variables I noticed)

Why this is so difficult I don't know...
Any ideas would be appreciated.
 
Back
Top