10 Replies - 6762 Views - Last Post: 09 August 2013 - 08:23 PM

#1 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Table Relationship in VB.NET

Posted 30 July 2013 - 09:55 PM

I'm developing a Inventory system and i want to create a table relationship betwwen the product_Table and order_Table, For example if the stocks is reduced in the order_Table, the 'stocks' in the product_Table is also updated. Any suggestions / help? Thanks!
Is This A Good Question/Topic? 0
  • +

Replies To: Table Relationship in VB.NET

#2 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Table Relationship in VB.NET

Posted 30 July 2013 - 10:56 PM

Check this link.

This post has been edited by nandureddy: 30 July 2013 - 10:57 PM

Was This Post Helpful? 0
  • +
  • -

#3 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Table Relationship in VB.NET

Posted 30 July 2013 - 11:11 PM

OK thank you :)

Hmm, Im using ms access database
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3599
  • View blog
  • Posts: 12,386
  • Joined: 12-December 12

Re: Table Relationship in VB.NET

Posted 31 July 2013 - 05:50 AM

Access does not have table-triggers. Access 2010 has Data Macros, which are similar, if you wanted to explore these. (I haven't delved into these a lot myself.)

Otherwise, you'll need to write the code for your VB.NET form(s) that performs the updates to the products table, when the orders table is updated.

However, from your original description (and your table structures) I suspect that you need to study table joins and relationships.

Join tables and queries :MSDN
We have many database tutorials here @DIC as well. Click the Tutorials link at the top of this page.
Was This Post Helpful? 1
  • +
  • -

#5 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Table Relationship in VB.NET

Posted 31 July 2013 - 08:45 PM

Thanks sir i will try that one, I try the code that will update 2 tables but its not working..the other table is not updating..
Was This Post Helpful? 0
  • +
  • -

#6 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Table Relationship in VB.NET

Posted 01 August 2013 - 09:06 AM

What is the code you are using? Post it here using the code tags.

This post has been edited by nandureddy: 01 August 2013 - 09:07 AM

Was This Post Helpful? 1
  • +
  • -

#7 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Table Relationship in VB.NET

Posted 06 August 2013 - 02:19 PM

Hi sorry for the late reply, here is my update command button:



Dim cmd1 As New OleDbCommand
Dim cmd2 As New OleDbCommand

 gdpcccon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\GDPCC\gdpcc.mdb")
            
            Dim strUpdate1 As String = "update priceTable set [Stocks] = '" & TextBox2.Text & "' where ID = " & IDTextBox.Text

  Dim strUpdate2 As String = "update orderTable set [Stocks] = '" & TextBox2.Text & "' where ID = " & IDTextBox.Text

cmd1 = New OleDbCommand(strUpdate1, gdpcccon)
cmd2 = New OleDbCommand(strUpdate2, gdpcccon)

con.Open()
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
con.Close()
refresh()



Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3599
  • View blog
  • Posts: 12,386
  • Joined: 12-December 12

Re: Table Relationship in VB.NET

Posted 06 August 2013 - 02:33 PM

Do you receive error messages? If so, post them.

Also print-out your strUpdate1 and 2 variables and try to execute them from the SQL View in Access.

This post has been edited by andrewsw: 06 August 2013 - 02:36 PM

Was This Post Helpful? 1
  • +
  • -

#9 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Table Relationship in VB.NET

Posted 07 August 2013 - 11:17 PM

Hi sir my problem earlier is the other table is not updating.. i try to google search and troubleshoot my code, and its now working! thanks! :)
Was This Post Helpful? 0
  • +
  • -

#10 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 01-October 12

Re: Table Relationship in VB.NET

Posted 09 August 2013 - 03:40 AM

View Postvbnewbeginer, on 07 August 2013 - 11:17 PM, said:

Hi sir my problem earlier is the other table is not updating.. i try to google search and troubleshoot my code, and its now working! thanks! :)/>


Hi,Im experiencing the same problem. Can you tell me what you did to update the field in table2 if the field in table1 has been changed. Please tell me what you did, I really need it. I
Was This Post Helpful? 0
  • +
  • -

#11 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Table Relationship in VB.NET

Posted 09 August 2013 - 08:23 PM

look 4 my code above , u just need to specify a unique value in the "where" statement, just like the ID# of the table
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1