Author Topic: Example Sql Database Code  (Read 1409 times)

BigKahuna59

  • Newbie
  • *
  • Posts: 1
    • View Profile
Example Sql Database Code
« on: July 09, 2021, 10:24:10 AM »
I have a project that needs to produce a ticket after each batch. I need to log about 130 tags from a Compactlogix processor to a sql database. I also need the option to send the ticket to a printer if check box selected. Does anyone have any example code showing how to move that many tickets to the database? I have been searching for a while. I am proficient in PLC code, VB, just a little. The ticket needs to be produced when a tag receives a value, the code than needs to reset the value in the PLC after the transfer to the database is complete. Thank you in advance for any help I may get. I have a VB project using OPC and RSLinx that does work, but really want to be rid of the RSLinx

MajorFault

  • Guest
Re: Example Sql Database Code
« Reply #1 on: July 09, 2021, 01:37:57 PM »
I have been searching for a while.
Where?  There is info all over the place.  Open Google and search for vb.net SQL, here's one:
https://www.youtube.com/watch?v=7Z4BGEHD-JQ&ab_channel=VBToolbox

SQL isn't hard, but there is some thought that should go into it before you get started.  How you create tables and organize data is very important.  If you don't understand that, this may be a challenge for you.

Getting the data into SQL is very simple.  I would use a datasubscriber to get the data from the PLC, then push to SQL.  I would make a time stamp column.  Depending on how important the data is, you may want to buffer the data in the PLC and when ready push to AHMI/SQL.  After successful insert, you then move to the next record, if necessary.

bachphi

  • Hero Member
  • *****
  • Posts: 674
    • View Profile
Re: Example Sql Database Code
« Reply #2 on: August 02, 2021, 07:13:04 AM »
Funny that you mentioned VBToolbox! 

 In this day and age, there are so MANY videos from wannabes that try to teach us dummies about SQL, and yet his videos are like invaluable gems that stood out from the rest. A legend in his own right.

Unfortunately, he's been living off the grid, he is still checking in every so often. I hope he is still doing OK from last June.
« Last Edit: August 02, 2021, 07:16:38 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================