Click here to Skip to main content
15,914,160 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to Accept Parameters in this Situation Pin
SHatchard9-Oct-07 6:08
SHatchard9-Oct-07 6:08 
AnswerRe: How to Accept Parameters in this Situation Pin
Dave Kreskowiak9-Oct-07 6:16
mveDave Kreskowiak9-Oct-07 6:16 
QuestionCheck if changes exist? Pin
Mr Oizo9-Oct-07 3:38
Mr Oizo9-Oct-07 3:38 
AnswerRe: Check if changes exist? Pin
Vimalsoft(Pty) Ltd9-Oct-07 4:02
professionalVimalsoft(Pty) Ltd9-Oct-07 4:02 
AnswerRe: Check if changes exist? Pin
Dave Kreskowiak9-Oct-07 4:58
mveDave Kreskowiak9-Oct-07 4:58 
GeneralRe: Check if changes exist? Pin
Mr Oizo9-Oct-07 5:50
Mr Oizo9-Oct-07 5:50 
GeneralRe: Check if changes exist? Pin
Dave Kreskowiak9-Oct-07 6:12
mveDave Kreskowiak9-Oct-07 6:12 
GeneralRe: Check if changes exist? Pin
Mr Oizo9-Oct-07 9:06
Mr Oizo9-Oct-07 9:06 
I think i have a big problem with my program.I have sat for 3 weeks with this data concurrency error and I can't fix it. it is happening in a project i'm writing for my thesis and at the moment i'm gonna fail just because this is stopping me from continuing with the rest of my project. the problem is that I can add data to a dataset but as soon as I try to edit the newly added data and save a data concurrency error appears(o records updated out of the expected 1 record(or similar to that)). I have read tons of articles and still can't find the problem. It's a single user environment, my dataset tables and database tables have the same field types and everything. the update statement looks fine. the only thing that i can assume is wrong is something to do with the fact that i have a datagridview and several textboxes bound to the underlying dataset and when I call "saveChanges" it tries to save the values from both the textbox for the column and the datagridview for the column. the only code used by my textboxes and datagrid is databinding code eg:


modbdaSongNewest2.ClearBeforeFill = True<br />
        modbdaSongNewest2.Fill(DsLibraryNewest2.Song)<br />
<br />
' bindingSong is a bindingsource object<br />
<br />
  bindingSong.DataSource = DsLibraryNewest2<br />
        bindingSong.DataMember = "Song"<br />
       <br />
      <br />
        dgSongProperties.DataSource = bindingSong



txtArtist.DataBindings.Add("Text",bindingSong, "Artist",_<br />
       True, DataSourceUpdateMode.OnPropertyChanged)




When adding new songs to the library I use the Openfiledialog and run a for loop for each file that was selected and add rows using this code which is pretty standard:


 Dim FileInfo As System.IO.FileInfo ' This variable will hold the selected file info<br />
        Dim drCurrentSong As dsLibraryNewest2.SongRow<br />
<br />
        If Not (dlgOpenFile Is Nothing) Then<br />
<br />
<br />
            For i = 0 To dlgOpenFile.FileNames.GetUpperBound(0)<br />
                FileInfo = My.Computer.FileSystem.GetFileInfo(dlgOpenFile.FileNames(i))<br />
                ' This will retrieve the foldername for the file<br />
                Dim folderPath As String =  FileInfo.DirectoryName<br />
                ' MsgBox(folderPath)<br />
                ' This will retrieve  file name for the file<br />
                Dim fileName As String = FileInfo.Name<br />
                'MsgBox(fileName)<br />
<br />
                '  This will retrieve the full path of the file <br />
                Dim absolutePath As String = FileInfo.FullName<br />
                ' MsgBox(absolutePath)<br />
<br />
                Try<br />
                    drCurrentSong = DsLibraryNewest2.Song.NewSongRow<br />
<br />
                    With drCurrentSong<br />
<br />
                        .FileName = fileName<br />
                        .FolderPath = folderPath<br />
                        .AbsolutePath = absolutePath<br />
<br />
                    End With<br />
                    DsLibraryNewest2.Song.AddSongRow(drCurrentSong)<br />
                    '   Call SaveChanges()<br />
<br />
                Catch ex As System.ArgumentException<br />
                    DsLibraryNewest2.Song(mintCurrent).CancelEdit()<br />
<br />
                Catch ex As System.Data.ConstraintException<br />
                    MessageBox.Show( _<br />
                   ex.Message, _<br />
                    "Error", MessageBoxButtons.OK)<br />
                    DsLibraryNewest2.Song(mintCurrent).CancelEdit()<br />
<br />
                End Try<br />
                mintCurrent += 1<br />
            Next<br />
<br />
        End If<br />
<br />
<br />
    End Sub









anyway that code all works fine. the problem is editing the data not adding it. So the only code I have for editing is the binding bit in the from load event and this bit:


Private Sub dgSongProperties_RowLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgSongProperties.RowLeave<br />
<br />
' this line below doesn't really do anything <br />
<br />
        dgSongProperties.Update()<br />
<br />
    End Sub<br />
<br />
<br />
<br />
<br />
<br />
<br />
    Private Sub BindingSource1_BindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.BindingCompleteEventArgs) Handles bindingSong.BindingComplete<br />
<br />
        'the following code Checks if the data source has been updated, and that no error has occured.<br />
        If e.BindingCompleteContext = BindingCompleteContext.DataSourceUpdate _<br />
            AndAlso e.Exception Is Nothing Then<br />
<br />
            ' If not, end the current edit.<br />
            e.Binding.BindingManagerBase.EndCurrentEdit()<br />
<br />
        End If<br />
<br />
<br />
    End Sub





i know you are really busy and I have probably just left something out or forgot to call something. My other forms all work correctly and update their data but this one with the datagridview that has textboxes bounded to the datatable has a problem? if you can help me then please do... time is running out for me. thank you

Mr Oizo
GeneralRe: Check if changes exist? Pin
Dave Kreskowiak9-Oct-07 11:52
mveDave Kreskowiak9-Oct-07 11:52 
GeneralRe: Check if changes exist? Pin
Mr Oizo9-Oct-07 22:33
Mr Oizo9-Oct-07 22:33 
GeneralRe: Check if changes exist? Pin
Patrick Etc.10-Oct-07 9:43
Patrick Etc.10-Oct-07 9:43 
Questionread a txt file in visual basic Pin
Rinki Mukheraji9-Oct-07 2:18
Rinki Mukheraji9-Oct-07 2:18 
AnswerRe: read a txt file in visual basic Pin
pmarfleet9-Oct-07 2:34
pmarfleet9-Oct-07 2:34 
AnswerRe: read a txt file in visual basic Pin
Dave Kreskowiak9-Oct-07 4:47
mveDave Kreskowiak9-Oct-07 4:47 
QuestionREG: VB Pin
rajasekar.mpbs9-Oct-07 2:08
rajasekar.mpbs9-Oct-07 2:08 
AnswerRe: REG: VB Pin
Dave Kreskowiak9-Oct-07 4:44
mveDave Kreskowiak9-Oct-07 4:44 
GeneralRe: REG: VB Pin
mr_lasseter9-Oct-07 6:11
mr_lasseter9-Oct-07 6:11 
GeneralRe: REG: VB Pin
Dave Kreskowiak9-Oct-07 6:44
mveDave Kreskowiak9-Oct-07 6:44 
Questionpropertygrid control Pin
balakpn9-Oct-07 1:22
balakpn9-Oct-07 1:22 
AnswerRe: propertygrid control Pin
Dave Kreskowiak9-Oct-07 4:42
mveDave Kreskowiak9-Oct-07 4:42 
QuestionVB.NET and designing of Patch Files Pin
Vimalsoft(Pty) Ltd9-Oct-07 0:53
professionalVimalsoft(Pty) Ltd9-Oct-07 0:53 
AnswerRe: VB.NET and designing of Patch Files Pin
Tom Deketelaere9-Oct-07 1:14
professionalTom Deketelaere9-Oct-07 1:14 
GeneralRe: VB.NET and designing of Patch Files Pin
Vimalsoft(Pty) Ltd9-Oct-07 1:21
professionalVimalsoft(Pty) Ltd9-Oct-07 1:21 
QuestionForm Control Pin
Sarfaraj Ahmed9-Oct-07 0:21
Sarfaraj Ahmed9-Oct-07 0:21 
AnswerRe: Form Control Pin
Dave Kreskowiak9-Oct-07 4:40
mveDave Kreskowiak9-Oct-07 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.