Note that there are some explanatory texts on larger screens.

plurals
  1. POsaving data from datagridview to multiple tables pointing one id in a table
    primarykey
    data
    text
    <p>i am working on vb.net windows form application ,,i have a data grid <img src="https://i.stack.imgur.com/kz9yP.png" alt="enter image description here">view,,that is loading data from two table..my data grid view something like this:</p> <p>I have two tables <code>1-&gt;CompanyMaster_tbl</code> in this having Two fields . <code>Cid and CompanyName</code>,</p> <blockquote> <p>Cid is the primary key of this table</p> </blockquote> <p>2-><code>DepartmentMaster_tbl</code> in this having 4 fields. <code>dtid,dtname,dtphon,dtmail,Cid</code>. </p> <blockquote> <p>dtid is the primary key,and Cid is the foreign key</p> </blockquote> <p>while clicking save button i want save the data in both table. in one company i want to save multiple departments. my Cid and dtid are autoincriment,,i mean Identity specication i set as true..in save button i given code like this,,</p> <pre><code> Dim sqlInsertT1 As String = "" Dim sqlInsertT2 As String = "" For i As Integer = 0 To gv.RowCount - 2 If gv.Rows(i).Cells("cmpny").Value &lt;&gt; "" Then sqlInsertT1 &amp;= "Insert Into CompanyMaster_tbl(CompanyName) Values ('" &amp; gv.Rows(i).Cells("cmpny").Value &amp; "');" Exetransaction(sqlInsertT1) End If Ccid = RecordID("Cid", "CompanyMaster_tbl", "CompanyName", gv.Rows(i).Cells("cmpny").Value) sqlInsertT2 &amp;= "Insert Into DepartmentMaster_tbl(dtname,dtphone,dtEmail,Cid) Values ('" &amp; gv.Rows(i).Cells("Dpmnt").Value &amp; "','" &amp; gv.Rows(i).Cells("dtphon").Value &amp; "','" &amp; gv.Rows(i).Cells("mail").Value &amp; "'," &amp; Ccid &amp; ");" Next Exetransaction(sqlInsertT2) </code></pre> <p>but i understood this logic is not enough for saving this data,,<br> in save button if i am editing something in grid view ,,i want to update that value in particular table<br> if any one know how to do it,,please help me to find out</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload