Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
GeneralCrystal Report Pin
| Muhammad Waqas Butt |29-Dec-04 1:00
professional| Muhammad Waqas Butt |29-Dec-04 1:00 
GeneralRe: Crystal Report Pin
Michael P Butler29-Dec-04 1:39
Michael P Butler29-Dec-04 1:39 
GeneralNumber to Word Pin
| Muhammad Waqas Butt |29-Dec-04 0:57
professional| Muhammad Waqas Butt |29-Dec-04 0:57 
GeneralRe: Number to Word Pin
Marc Clifton29-Dec-04 3:11
mvaMarc Clifton29-Dec-04 3:11 
Generalchanging row color in a datagrid Pin
Salmanzz28-Dec-04 19:47
Salmanzz28-Dec-04 19:47 
GeneralRe: changing row color in a datagrid Pin
Identity Undisclosed28-Dec-04 20:25
Identity Undisclosed28-Dec-04 20:25 
GeneralRe: changing row color in a datagrid Pin
Robert Rohde28-Dec-04 22:08
Robert Rohde28-Dec-04 22:08 
GeneralAutonumber is not showing up in the child table Pin
msogun28-Dec-04 18:16
msogun28-Dec-04 18:16 
I am writing a c# application that save record into two table that has a relationship. But when inserting new data, the auto id suppose to be in the detail table but not. I could not figure it out. Please turn the light on. Here is the code.
================================================

static void ExPnamesAdapter_OnRowUpdate(object sender, OleDbRowUpdatedEventArgs e)
{ OleDbCommand oCmd = new OleDbCommand("SELECT @@IDENTITY", e.Command.Connection);
e.Row["ID"] = oCmd.ExecuteScalar();
e.Row.AcceptChanges();

}

private void btnSav_Click(object sender, System.EventArgs e)
{

OleDbConnection myConnection = new OleDbConnection( CONNECTION_STRING );

//// Create the DataSet
DataSet ds1 = new DataSet();

// Fill the Dataset with Names, map Default Tablename
//// "Table" to "names".
OleDbDataAdapter namesAdapter = new OleDbDataAdapter("Select LastName,FirstName,Initial,SSN,ExpungeID FROM Name",myConnection);

namesAdapter.RowUpdated += new OleDbRowUpdatedEventHandler(ExPnamesAdapter_OnRowUpdate);

OleDbCommandBuilder namesCmdBuilder = new OleDbCommandBuilder(namesAdapter);

namesAdapter.TableMappings.Add("Table","Name");
namesAdapter.Fill(ds1);

/// Fill the Dataset with Orders, map Default Tablename
/// "Table" to "detail".
OleDbDataAdapter detailAdapter = new OleDbDataAdapter("SELECT Type,ReceiveDate,ProcessDate,RejectDate,ReasonReject,PJ_ClafLet,Misc,Misc1,Misc2,Misc3,Status,ID FROM Detail",myConnection);

OleDbCommandBuilder detailCmdBuilder = new OleDbCommandBuilder(detailAdapter);

detailAdapter.TableMappings.Add("Table","Detail");
detailAdapter.Fill(ds1);

System.Data.DataRelation relCustOrd;
System.Data.DataColumn colMaster1;
System.Data.DataColumn colDetail1;
colMaster1 = ds1.Tables["Name"].Columns["ID"];
colDetail1 = ds1.Tables["Detail"].Columns["ID"];
relCustOrd = new System.Data.DataRelation("RelCustOrd",colMaster1,colDetail1);
ds1.Relations.Add(relCustOrd);



DataRow namesRow = ds1.Tables ["Name"].NewRow();
namesRow["LastName"] = this.txtlastname.Text;
namesRow["FirstName"] = this.txtfirstname.Text;
namesRow["Initial"] = this.txtInitial.Text;

ds1.Tables["Name"].Rows.Add(namesRow);

DataRow detailRow = ds1.Tables["Detail"].NewRow();

detailRow["Type"] = "A";
detailRow["Misc"] = "Testing and Working not";
detailRow["Misc1"] = "I hope this will work";
ds1.Tables["Detail"].Rows.Add(detailRow);

detailRow.SetParentRow(namesRow);

namesAdapter.Update(ds1, "Name");
detailAdapter.Update(ds1, "Detail");

myConnection.Close();

}






Mso
GeneralRe: "This row already belongs to this table." Pin
Robert Rohde28-Dec-04 22:05
Robert Rohde28-Dec-04 22:05 
Generalread a .xsd file and write it on a xml file with data's automatically written Pin
dhol28-Dec-04 16:55
dhol28-Dec-04 16:55 
Generalscreen capture using WMEncoder Pin
Member 161799928-Dec-04 13:11
Member 161799928-Dec-04 13:11 
GeneralCapture the Fn key on a laptop Pin
sparker6228-Dec-04 9:31
sparker6228-Dec-04 9:31 
GeneralRe: Capture the Fn key on a laptop Pin
Heath Stewart28-Dec-04 10:08
protectorHeath Stewart28-Dec-04 10:08 
GeneralRe: Capture the Fn key on a laptop Pin
sparker6228-Dec-04 10:37
sparker6228-Dec-04 10:37 
GeneralRe: Capture the Fn key on a laptop Pin
Heath Stewart28-Dec-04 10:39
protectorHeath Stewart28-Dec-04 10:39 
QuestionHow to write { character to a text file? Pin
James Rossiter28-Dec-04 7:43
James Rossiter28-Dec-04 7:43 
AnswerRe: How to write { character to a text file? Pin
Guinness4Strength28-Dec-04 7:53
Guinness4Strength28-Dec-04 7:53 
AnswerRe: How to write { character to a text file? Pin
leppie28-Dec-04 8:21
leppie28-Dec-04 8:21 
Questionupdate listview subitems without redrawing the whole row? Pin
dfsgdsfgdfg28-Dec-04 7:39
dfsgdsfgdfg28-Dec-04 7:39 
GeneralA customized TabControl (no tabs..) Pin
R W Briggs28-Dec-04 7:23
R W Briggs28-Dec-04 7:23 
GeneralTextBox color Pin
picasso228-Dec-04 7:22
picasso228-Dec-04 7:22 
GeneralRe: TextBox color Pin
Identity Undisclosed28-Dec-04 7:42
Identity Undisclosed28-Dec-04 7:42 
GeneralRe: TextBox color Pin
R W Briggs28-Dec-04 9:09
R W Briggs28-Dec-04 9:09 
GeneralCombo ControlArray - Selected Item Pin
Sylesh28-Dec-04 7:19
Sylesh28-Dec-04 7:19 
GeneralRe: Combo ControlArray - Selected Item Pin
Guinness4Strength28-Dec-04 7:56
Guinness4Strength28-Dec-04 7:56 

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.