Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
GeneralRe: .net equivalent of ddx + q about anchoring Pin
roel_5-Aug-05 1:17
roel_5-Aug-05 1:17 
GeneralRe: .net equivalent of ddx + q about anchoring Pin
Pradyumna Gogte5-Aug-05 2:01
Pradyumna Gogte5-Aug-05 2:01 
GeneralRe: .net equivalent of ddx + q about anchoring Pin
Dan Neely5-Aug-05 2:04
Dan Neely5-Aug-05 2:04 
Questionhow to define length of double dimension array Pin
Anonymous4-Aug-05 22:48
Anonymous4-Aug-05 22:48 
AnswerRe: how to define length of double dimension array Pin
mav.northwind4-Aug-05 22:58
mav.northwind4-Aug-05 22:58 
GeneralRe: how to define length of double dimension array Pin
Anonymous4-Aug-05 23:08
Anonymous4-Aug-05 23:08 
GeneralRe: how to define length of double dimension array Pin
Guffa4-Aug-05 23:52
Guffa4-Aug-05 23:52 
GeneralDelete related record problem Pin
Ming Luo4-Aug-05 22:33
Ming Luo4-Aug-05 22:33 
Hello Everyone!
I have two related table Customer and Address, one customer may have several address. The source database is in access. I use the following code to populate the dataset and define the relationship between customer table and address table.
<br />
cus_adaptr.SelectCommand = cn.CreateCommand();<br />
cus_adaptr.SelectCommand.CommandText = "Select * from Customer";<br />
cus_adaptr.MissingSchemaAction = MissingSchemaAction.AddWithKey;<br />
cus_adaptr.Fill(ds, "Customer");<br />
new OleDbCommandBuilder(cus_adaptr);	<br />
DataTable customer = ds.Tables["Customer"];<br />
<br />
addr_adaptr.SelectCommand = cn.CreateCommand();<br />
addr_adaptr.SelectCommand.CommandText = "Select * from Address";<br />
addr_adaptr.MissingSchemaAction = MissingSchemaAction.AddWithKey;<br />
addr_adaptr.Fill(ds, "Address");<br />
new OleDbCommandBuilder(addr_adaptr);<br />
DataTable address = ds.Tables["Address"];<br />
<br />
DataRelation cus_addr = new DataRelation("cus_addr",customer.Columns["cus_id"], address.Columns["cus_id"]);			<br />
ds.Relations.Add(cus_addr);<br />

Then I defined a function to store the changes made in the dataset.
<br />
public static void save_to_database(string table)<br />
{<br />
    System.Data.OleDb.OleDbDataAdapter <br />
	dbAdaptr = new OleDbDataAdapter("Select * from "+table, cn);<br />
    new OleDbCommandBuilder(dbAdaptr);<br />
    DataTable atable = ds.Tables[table].GetChanges();<br />
    int i = main_form.ds.Tables["Customer"].Rows.Count;<br />
    try <br />
    {<br />
	dbAdaptr.Update(ds, table);				<br />
    } 			<br />
    catch (Exception er)<br />
    {<br />
	MessageBox.Show("Cannot update invoice.mdb! " + er.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);<br />
    }<br />
    ds.Tables[table].AcceptChanges();<br />
}<br />

When I delete a customer record from the customer table then save it as:
save_to_database("Customer");
save_to_database("Address");
An error happens when save the address table which says:
"Concurrency Violation: the delete command affected 0 records." Does anybody know how to avoid this happen?
Also I can loop a field in address table if I delete any record, it says "can't access the deleted rows." Does anybody know how to bypass the deleted row so I still can loop the rows which are not deleted?

Thanks in advance

Asura
GeneralSql Paraments C# Pin
| Muhammad Waqas Butt |4-Aug-05 21:39
professional| Muhammad Waqas Butt |4-Aug-05 21:39 
GeneralRe: Sql Paraments C# Pin
J4amieC4-Aug-05 22:14
J4amieC4-Aug-05 22:14 
GeneralRe: Sql Paraments C# Pin
| Muhammad Waqas Butt |4-Aug-05 22:32
professional| Muhammad Waqas Butt |4-Aug-05 22:32 
GeneralRe: Sql Paraments C# Pin
J4amieC4-Aug-05 23:44
J4amieC4-Aug-05 23:44 
GeneralRe: Sql Paraments C# Pin
Guffa4-Aug-05 23:55
Guffa4-Aug-05 23:55 
GeneralRe: Sql Paraments C# Pin
Dead Skin Mask5-Aug-05 3:05
Dead Skin Mask5-Aug-05 3:05 
GeneralC# as scripting lang in MFC App Pin
Ning Hu4-Aug-05 21:19
Ning Hu4-Aug-05 21:19 
GeneralRe: C# as scripting lang in MFC App Pin
WillemM5-Aug-05 1:05
WillemM5-Aug-05 1:05 
GeneralNot able to create Event Handler Pin
Aneeel4-Aug-05 19:49
Aneeel4-Aug-05 19:49 
Generalconditions problem Pin
nidhelp4-Aug-05 16:47
nidhelp4-Aug-05 16:47 
GeneralRe: conditions problem Pin
Mohamad Al Husseiny4-Aug-05 16:50
Mohamad Al Husseiny4-Aug-05 16:50 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 16:58
nidhelp4-Aug-05 16:58 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 17:35
protectorChristian Graus4-Aug-05 17:35 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:07
nidhelp4-Aug-05 18:07 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 18:14
protectorChristian Graus4-Aug-05 18:14 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:32
nidhelp4-Aug-05 18:32 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 18:56
protectorChristian Graus4-Aug-05 18: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.