Anja

Anja

  • NA
  • 15
  • 0

passing data into another form

Jul 23 2006 1:37 PM
Hi,

I have the following code, which works perfect, when I makes af DataGridView with drag and drop (the code pass over the FakturaId to the new form, so I can make a select on this)

System.Data.DataRowView SelectedRowView;

fakturasystemDataSet.FakturaRow SelectedRow;


SelectedRowView = (System.Data.DataRowView)fakturaBindingSource.Current;

SelectedRow = (fakturasystemDataSet.FakturaRow)SelectedRowView.Row;

FakturaVis FakturaVisForm = new FakturaVis();

FakturaVisForm.LoadFakturaVis(SelectedRow.FakturaID);

FakturaVisForm.Show();


But now I have made my own dataset and adapter and I have some problems with the above code. I don't know, how I get the FakturaRow in intellisense (how I get this into the code, where I instansiate the dataset and the adapter)?

Is my dsView the same as, the system generated fakturaBindingSource?

My code where I instansiate the dataset and the adapters:

private void loadKundeFaktura()

{

//create a connection string to the access database

OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;

User Id=password=;

Data Source=" + myDB);

// Create the DataSet

ds = new DataSet("KundeFaktura");

// Fill the Dataset with Kunder, map Default Tablename

// "Table" to "Kunder".

da1 = new OleDbDataAdapter("SELECT KundeId, Navn, Adresse, Postnr, Byen,
Telefonnr, Mobilnr, EmailAdr, Noter FROM Kunder", cn);

da1.TableMappings.Add("Table", "Kunder");

da1.Fill(ds);

// Fill the Dataset with Faktura, map Default Tablename

// "Table" to "Faktura". ORDER BY FakturaID DESC

da2 = new OleDbDataAdapter("SELECT FakturaID, KundeID, Dato, BetalingsDato,
Betalt FROM Faktura ORDER BY FakturaID DESC", cn);

da2.TableMappings.Add("Table", "Faktura");

da2.Fill(ds);



// Establish the Relationship "RelOrdDet"

// between Kunder ---< [Faktura]

System.Data.DataRelation relOrdDet;

System.Data.DataColumn colMaster2;

System.Data.DataColumn colDetail2;

colMaster2 = ds.Tables["Kunder"].Columns["KundeId"];

colDetail2 = ds.Tables["Faktura"].Columns["KundeID"];

relOrdDet = new System.Data.DataRelation("RelOrdDet", colMaster2,
colDetail2);

ds.Relations.Add(relOrdDet);

// The DataViewManager returned by the DefaultViewManager

// property allows you to create custom settings for each

// DataTable in the DataSet.

dsView = ds.DefaultViewManager;

// Databinding for the Grid's

dgrKunder.DataSource = dsView;

dgrKunder.DataMember = "Kunder";

dgrFaktura.DataSource = dsView;

dgrFaktura.DataMember = "Kunder.RelOrdDet";

}


Kind regards,
simsen :-)

Answers (2)