资源描述:
《AB-上位机配方使用.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.定义ACCESSmdb数据库表格格式在DesignView模式设计Recipe记录表格定义Recipe组成设置RecipeNo为PrimaryKey检索主键2.定义系统数据源ODBC数据源指向recipe.mdb3.定义FTVIEWSE标签数据库中标签变量AI01-05代表数据库Recipe显示缓冲变量PLC01-05代表PLCRecipe变量RecipeNo代表显示数据库内Recipe号码RunRecipeNo代表PLC运行Recipe号码4.运行测试画面输入检索数据库Recipe号码点击读取按钮点击
2、下装按钮修改Recipe内容,点击保存新建Recipe号码,点击保存点击删除,删除当前数据库Recipe记录点击上载,上载PLC内Recipe5.查看程序Recipe读取程序PublicSubRead_DB()DimcnAsADODB.ConnectionDimrsAsADODB.RecordsetDimgsqlsAsStringDimRIndexAsStringDimAI_01,AI_02,AI_03,AI_04,AI_05AsStringSetcn=NewADODB.ConnectionSetrs=Ne
3、wADODB.Recordsetcn.Open"persistsecurityinfo=false;datasource=odbcrecipe;"RIndex=NumericInput6.Valuegsqls="SELECT*FROMRecipeTWHERERecipeNo="+RIndexrs.Opengsqls,cnIfrs.EOFAndrs.BOFThen'MsgBox"查询失败!"ExecuteCommand"SetAI010"ExecuteCommand"SetAI020"ExecuteComma
4、nd"SetAI030"ExecuteCommand"SetAI040"ExecuteCommand"SetAI050"ElseAI_01=rs.Fields("AI01")AI_02=rs.Fields("AI02")AI_03=rs.Fields("AI03")AI_04=rs.Fields("AI04")AI_05=rs.Fields("AI05")'NumericInput13.Value=rs.Fields("AI03")ExecuteCommand"SetAI01"+AI_01ExecuteCo
5、mmand"SetAI02"+AI_02ExecuteCommand"SetAI03"+AI_03ExecuteCommand"SetAI04"+AI_04ExecuteCommand"SetAI05"+AI_05EndIfrs.Closecn.CloseEndSubRecipe保存程序PublicSubWrite_DB()DimcnAsADODB.ConnectionDimrsAsADODB.RecordsetDimgsqlsAsStringDimRIndexAsStringDimAI_01,AI_02,
6、AI_03,AI_04,AI_05AsStringSetcn=NewADODB.ConnectionSetrs=NewADODB.Recordsetcn.Open"persistsecurityinfo=false;datasource=odbcrecipe;"RIndex=NumericInput6.Valuegsqls="SELECT*FROMRecipeTWHERERecipeNo="+RIndexrs.Opengsqls,cn,adOpenDynamic,adLockPessimisticIfrs.
7、EOFAndrs.BOFThen'MsgBox"查询失败!"rs.AddNewrs.Fields("RecipeNo")=CInt(RIndex)EndIfrs.Fields("AI01")=NumericInput1.Valuers.Fields("AI02")=NumericInput2.Valuers.Fields("AI03")=NumericInput3.Valuers.Fields("AI04")=NumericInput4.Valuers.Fields("AI05")=NumericInput
8、5.Valuers.Updaters.Closecn.CloseEndSubRecipe删除程序PublicSubDelete_Recipe()DimcnAsADODB.ConnectionDimrsAsADODB.RecordsetDimgsqlsAsStringDimRIndexAsStringDimAI_01,AI_02,AI_03,AI_04,AI_05AsStringSetcn=NewADODB.Con