Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 17th, 2005, 07:28 PM
swbouse's Avatar
swbouse swbouse is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Phx. AZ
Posts: 221 swbouse User rank is Corporal (100 - 500 Reputation Level)swbouse User rank is Corporal (100 - 500 Reputation Level)swbouse User rank is Corporal (100 - 500 Reputation Level)swbouse User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 19 h 12 m 21 sec
Reputation Power: 6
Send a message via MSN to swbouse
Getting a 'System.ArgumentException' error

I am get this error when trying to insert data into a database
Quote:
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: System.InvalidCastException: Specified cast is not valid.
at System.Convert.ToInt32(Object value)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <> in ID Column. Expected type is Int32.


Here is my code for the sub routine
Code:
        Dim newRow(5) As Object
        Dim dcIdColumn As DataColumn
        dcIdColumn = New DataColumn
        dcIdColumn.AllowDBNull = True

        Dim intX As Integer
        Me.dlgOpen.Filter = "MP3 file (*.mp3)|*.mp3|WMA Files (*.wma)|*.wma|All Files (*.*)|*.*"
        Me.dlgOpen.InitialDirectory = Application.StartupPath
        Me.dlgOpen.FilterIndex = 1
        Me.dlgOpen.Title = "Open Music File"

        'open dialog and accept user input
        If Me.dlgOpen.ShowDialog() = DialogResult.OK Then
            strCurrentFile = Me.dlgOpen.FileName
            Dim objReader As StreamReader = New StreamReader(strCurrentFile)
            objReader.Close()
            objReader = Nothing

            ' Set the values of the array.
            newRow(0) = dcIdColumn
            newRow(1) = InputBox("Enter Title")
            newRow(2) = InputBox("Enter Artist Name")
            newRow(3) = InputBox("Enter Notes, (i.e. genre)")
            newRow(4) = InputBox("Enter File Type")
            newRow(5) = strCurrentFile

            ' Add the new row to the rows collection
            Dim drNewSong As DataRow
            dtMusic.BeginLoadData()
            drNewSong = dtMusic.LoadDataRow(newRow, True)
            dtMusic.EndLoadData()
            MessageBox.Show("File added to database", "Save Complete")

            'Add to List Boxes 
            Me.lstTitle.Items.Add(newRow(1))
            Me.lstArtist.Items.Add(newRow(2))
            Me.lstNote.Items.Add(newRow(3))
            Me.lstType.Items.Add(newRow(4))
            Me.lstFileName.Items.Add(newRow(5))

        End If


This is my first attempt to insert data into VB 2003. Please let me know if it is wrong. Thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Getting a 'System.ArgumentException' error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT