none
Update MS Access Database with VS2010 RRS feed

  • Question

  • Hi all

    I have a MS Access database that I've connected with VS2010. I have used the DataSource Explorer for that.

    Now, I can work with the DataSet, i can fill, edit etc. But I don't get any data into my Access database.

    Here's a part of my code:

    private static void addPdf(Pdf p) {
                DataRow[] hits = dataSet.Tables["PdfDateien"].Select("Dateipfad='" + p.Path + "'");
                if (hits.GetLength(0) == 0) {
                    DataRow row = dataSet.Tables["PdfDateien"].NewRow();
                    int pdf_id = (int)row[0];
                    row[1] = p.Path;
                    row[2] = p.Name;
                    dataSet.Tables["PdfDateien"].Rows.Add(row);
    
                    row = dataSet.Tables["PdfDetails"].NewRow();
                    row[0] = pdf_id;
                    row[1] = p.Title;
                    row[2] = p.Author;
                    dataSet.Tables["PdfDetails"].Rows.Add(row);
    
                    foreach (string subject in p.GetSubjects()) {
                        hits = dataSet.Tables["Sammlungen"].Select("Titel='" + subject + "'");
                        int subject_id;
                        if (hits.GetLength(0) == 0) {
                            row = dataSet.Tables["Sammlungen"].NewRow();
                            subject_id = (int)row[0];
                            row[1] = subject;
                            dataSet.Tables["Sammlungen"].Rows.Add(row);
                        } else {
                            subject_id = (int)hits[0][0];
                        }
    
                        hits = dataSet.Tables["Sammlung"].Select("Sammlung_ID='" + subject_id + "' AND Pdf_ID='" + pdf_id +"'");
                        if (hits.GetLength(0) == 0) {
                            row = dataSet.Tables["Sammlung"].NewRow();
                            row[1] = subject_id;
                            row[2] = pdf_id;
                            dataSet.Tables["Sammlung"].Rows.Add(row);
                        }
                    }
                }
            }

    private void refreshPdfFiles_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
                Console.WriteLine(pdfFileAdapter.Update(dataSet));
                Console.WriteLine(pdfDetailsAdapter.Update(dataSet));
                Console.WriteLine(pdfCollectionsAdapter.Update(dataSet));
                Console.WriteLine(pdfCollectionAdapter.Update(dataSet));
    
                this.valid = true;
                Console.WriteLine("Finished");
            }

    The output is:

    177
    177
    5
    177

    I've searched a long time in the internet but nothing fixed my problem.

    Please help me

    • Moved by litdev Thursday, January 10, 2013 6:38 PM (From:Small Basic)
    Thursday, January 10, 2013 2:54 PM

Answers

All replies