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
| using System; | |
| using System.Windows.Forms; | |
| using System.IO; | |
| namespace MusicOrganiser | |
| { | |
| public partial class NewEntry : Form | |
| { | |
| Form1 mainForm; | |
| public NewEntry(Form1 mainForm) | |
| { | |
| this.mainForm = mainForm; | |
| InitializeComponent(); | |
| } | |
| private void button1_Click(object sender, EventArgs e) | |
| { | |
| this.folderBrowserDialog1.ShowNewFolderButton = false; | |
| DialogResult result = this.folderBrowserDialog1.ShowDialog(); | |
| if (result == DialogResult.OK) | |
| { | |
| // retrieve the name of the selected folder | |
| DirectoryInfo dir = new DirectoryInfo(this.folderBrowserDialog1.SelectedPath); | |
| // Entries for the first table | |
| mainForm.categoryTextBox.Text = comboBox1.Text; | |
| mainForm.artistTextBox.Text = textBox1.Text; | |
| mainForm.albumTextBox.Text = dir.Name; | |
| DataMusicDataSet.SongFilesRow newrow = dataMusicDataSet1.SongFiles.NewSongFilesRow(); | |
| //Now to get every song in the folder or cd | |
| foreach (FileInfo fi in dir.GetFiles()) | |
| { | |
| newrow.Song = fi.ToString(); // Getting filename | |
| newrow.SongUrl = fi.FullName; // Getting full path to play the song when click | |
| dataMusicDataSet1.SongFiles.Rows.Add(newrow); | |
| //mainForm.songbindingNavigator.BindingSource.Add(newrow); | |
| } | |
| } | |
| else | |
| { | |
| //If cancel close form NewEntry | |
| this.Close(); | |
| } | |
| } | |
| private void OK_Click(object sender, EventArgs e) | |
| { | |
| this.Close(); | |
| } | |
| } | |
| } | |
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
Bechir BejaouiPosted Dec 5, 2008, 6:33 PM