Hi there,
Ok I have this problem:
I have a databound datagridview from a child table with four collums in it:

SongName
SongUrl

CdNumber that is F_key
SongNumber that is primary key identity yes

none of them accept null value

CdNumber is the F_key from the parent CdNumber that is primary key

so my question is when I add row how do I enter the info for CdNumber and SongNumber
because getting error that CdNumber and SongNumber can't be null

1 using System;   
2 using System.Windows.Forms;   
3 using System.IO;   
4   
5 namespace MusicOrganiser   
6 {   
7     public partial class NewEntry : Form   
8     {   
9   
10   
11         Form1 mainForm;   
12         public NewEntry(Form1 mainForm)   
13         {   
14             this.mainForm = mainForm;   
15   
16             InitializeComponent();             
17         }   
18   
19         private void button1_Click(object sender, EventArgs e)   
20         {               
21             this.folderBrowserDialog1.ShowNewFolderButton = false;   
22             DialogResult result = this.folderBrowserDialog1.ShowDialog();   
23             if (result == DialogResult.OK)   
24             {                 
25                 // retrieve the name of the selected folder   
26                 DirectoryInfo dir = new DirectoryInfo(this.folderBrowserDialog1.SelectedPath);   
27   
28                 // Entries for the first table    
29                 mainForm.categoryTextBox.Text = comboBox1.Text;   
30                 mainForm.artistTextBox.Text = textBox1.Text;   
31                 mainForm.albumTextBox.Text = dir.Name;   
32                    
33                 DataMusicDataSet.SongFilesRow newrow = dataMusicDataSet1.SongFiles.NewSongFilesRow();   
34                    
35                 //Now to get every song in the folder or cd   
36                 foreach (FileInfo fi in dir.GetFiles())   
37                 {   
38   
39                     newrow.Song = fi.ToString(); // Getting filename   
40                     newrow.SongUrl = fi.FullName; // Getting full path to play the song when click   
41   
42                     dataMusicDataSet1.SongFiles.Rows.Add(newrow);   
43                     //mainForm.songbindingNavigator.BindingSource.Add(newrow);   
44                        
45                 }                   
46             }   
47             else  
48             {   
49                 //If cancel close form NewEntry   
50                 this.Close();   
51             }   
52                
53   
54         }   
55   
56         private void OK_Click(object sender, EventArgs e)   
57         {            
58             this.Close();   
59         }   
60   
61            
62     }   
63 }   
64

When running the program and enter everything to the datagrid manualy everything works 100% but I want to be able to enter automaticly from the second form. I don't have any problem for the first table it is when it come to the second one for the song table

Well then, you need to supply the additional data as in your own words "none of them accept null value". You cant expect it to work.

36                 foreach (FileInfo fi in dir.GetFiles())   
37                 {   
38   
39                     newrow.Song = fi.ToString(); // Getting filename   
40                     newrow.SongUrl = fi.FullName; // Getting full path to play the song when click   
41   
42                     dataMusicDataSet1.SongFiles.Rows.Add(newrow);

Add the other fields.

Thanks for replying the thing is The SongNumber I can live without it and could always take out the auto increment off and just put a counter in the loop. Where the problem is it the F_Key that I have to find a way to include it in there have a Ideal about how I sould get it from datagridview1 " Table1"

here a nother way to explain what i am looking for

Ok here the thing : how would you go if you have a datagridview that contain the name of a folder the next datagriview will display the files in the folder it is very simple to do if you use the datagriview manualy to insert all the info it works like a charm but my problem I want to press one buton and it will populate the second datagriview with all the files with out having to insert them manualy.

so what would be the code for that

This article has been dead for over six months. Start a new discussion instead.