当前位置: 首页 > news >正文

快速建站套餐社交网站 模板

快速建站套餐,社交网站 模板,建筑人才网 珠海,成都新闻最新消息在项目中需要在一定条件满足时#xff0c;保存一些数据到数据库中#xff0c;并可根据条件查询。考虑到WinCC6.2以后采用的就是SQL Server2005数据库#xff0c;所以直接利用该数据库即可#xff0c;通过SQL Server Management Studio#xff08;SSMS#xff09;可以创建…  在项目中需要在一定条件满足时保存一些数据到数据库中并可根据条件查询。考虑到WinCC6.2以后采用的就是SQL Server2005数据库所以直接利用该数据库即可通过SQL Server Management StudioSSMS可以创建自己的数据库并按要求创建好表。 一、数据库连接 在SQL Server Management StudioSSMS中创建名为evcp的数据库再创建名为evcp的表然后根据需要创建Columns在本项目中创建了norder流水号、pileno桩号、cardno卡号、operno员工号、energy电量、cost金额、period时长、rate费率、pdate日期和ptime时间。 在本项目中采用ODBC的方式连接数据库首先在控制面板中创建好数据源配置好SQL Server驱动数据源命名为evcs。 二、数据写入 要求在一个状态量值为1的时候完成数据库的保存等数据保存完后将状态量清0。 1、先在全局脚本VBS项目模块中创建函数savedata代码如下 Sub savedata Dim objConnection Dim objCommand Dim objRecordset Dim strConnectionString Dim strSQL Dim norder,pileno,cardno,operno,energy,cost,period,rate,pdate,ptimenorderHMIRuntime.Tags(norder).Read pileno HMIRuntime.Tags(pileno).Read cardnoHMIRuntime.Tags(cardno).Read operno HMIRuntime.Tags(operno).Read energy HMIRuntime.Tags(energy).Read cost HMIRuntime.Tags(cost).Read period HMIRuntime.Tags(period).Read rate HMIRuntime.Tags(rate).Read pdate HMIRuntime.Tags(pdate).Read ptime HMIRuntime.Tags(ptime).ReadstrConnectionString ProviderMSDASQL;DSNevcs;UID;PWD; Set objConnection CreateObject(ADODB.Connection) objConnection.ConnectionString strConnectionString objConnection.OpenSet objRecordset CreateObject(ADODB.Recordset) Set objCommand CreateObject(ADODB.Command) objCommand.ActiveConnection objConnectionstrSQL insert into evcp (norder,pileno,cardno,operno,energy,cost,period,rate,pdate,ptime) values (_ norder,_ pileno,_ cardno,_ operno,_ energy,_ cost,_ period,_ rate,_ pdate,_ ptime) MsgBox (strSQL) objCommand.CommandText strSQL objCommand.ExecuteSet objCommand Nothing objConnection.Close Set objRecordset Nothing Set objConnection Nothing End Sub 2、在全局脚本VBS动作中创建1秒周期的周期性出发动作并添加如下代码 Option Explicit Function action Dim v1 v1HMIRuntime.Tags(satuse).ReadIf v1 Then Call savedata HMIRuntime.Tags(satuse).Write 0 End if End Function 这样当satuse值为1时系统自动保存数据 三、数据查询 数据的查询要复杂一些需要用到MSFlexGrid控件、MS Form2 ComboBox控件和MS Form2 TextBox这几个控件可以单独注册也可以安装VB6后自动添加。 在查询页面上添加打开页面执行脚本如下 Sub OnOpen()                          Dim MSFlexGrid1,cb1,tb1,tb2 Set MSFlexGrid1 ScreenItems(控件1) Set cb1 ScreenItems(cb1) Set tb1 ScreenItems(tb1) Set tb2 ScreenItems(tb2) MSFlexGrid1.ClearMSFlexGrid1.ColWidth(0) 620 MSFlexGrid1.ColWidth(1) 1500 MsFlexGrid1.ColWidth(2) 1500 MSFlexGrid1.ColWidth(3) 1500 MSFlexGrid1.ColWidth(4) 1500 MSFlexGrid1.ColWidth(5) 1500 MsFlexGrid1.ColWidth(6) 1500 MSFlexGrid1.ColWidth(7) 1500 MSFlexGrid1.ColWidth(8) 1600 MSFlexGrid1.ColWidth(9) 2000 MsFlexGrid1.ColWidth(10) 2000MSFlexGrid1.TextMatrix(0,0) 编号 MSFlexGrid1.TextMatrix(0,1) 流水号 MSFlexGrid1.TextMatrix(0,2) 桩号 MSFlexGrid1.TextMatrix(0,3) 卡号 MSFlexGrid1.TextMatrix(0,4) 操作员号 MSFlexGrid1.TextMatrix(0,5) 电量度 MSFlexGrid1.TextMatrix(0,6) 金额元 MSFlexGrid1.TextMatrix(0,7) 时长分 MSFlexGrid1.TextMatrix(0,8) 费率元/度 MSFlexGrid1.TextMatrix(0,9) 日期 MSFlexGrid1.TextMatrix(0,10) 时间 MSFlexGrid1.ColAlignment(0) 4 MSFlexGrid1.ColAlignment(1) 4 MSFlexGrid1.ColAlignment(2) 4 MSFlexGrid1.ColAlignment(3) 4 MSFlexGrid1.ColAlignment(4) 4 MSFlexGrid1.ColAlignment(5) 4 MSFlexGrid1.ColAlignment(6) 4 MSFlexGrid1.ColAlignment(7) 4 MSFlexGrid1.ColAlignment(8) 4 MSFlexGrid1.ColAlignment(9) 4 MSFlexGrid1.ColAlignment(10) 4Dim i For i 1 To 39 Step 1 MSFlexGrid1.TextMatrix(i,0) i Nextcb1.Text* cb1.AddItem * cb1.AddItem 1 cb1.AddItem 2 tb1.Text* tb2.Text*End Sub 这段代码主要是用来初始化控件的显示。 在查询按钮加入相应的代码实现三个键值桩号、卡号、操作员号条件组合的查询代码如下 Sub Click(Byval Item) Dim objConnection Dim objCommand Dim objRecordset Dim strConnectionString Dim strSQL Dim MSFlexGrid1,cb1,tb1,tb2 Dim i1,i2,cv1,cv2,cv3,cv Set MSFlexGrid1 ScreenItems(控件1) Set cb1 ScreenItems(cb1) Set tb1 ScreenItems(tb1) Set tb2 ScreenItems(tb2)清除原有记录 For i1 1 To 39 Step 1 For i21 To 10 Step 1 MSFlexGrid1.TextMatrix(i1, i2) Next NextstrConnectionString ProviderMSDASQL;DSNevcs;UID;PWD; Set objConnection CreateObject(ADODB.Connection) objConnection.ConnectionString strConnectionString objConnection.Open Set objRecordset CreateObject(ADODB.Recordset) Set objCommand CreateObject(ADODB.Command) objCommand.ActiveConnection objConnectioncv10 cv20 cv30 If cb1.Text* Then cv14 End IfIf tb1.Text* Then cv22 End ifIf tb2.Text* Then cv31 End If cvcv1cv2cv3 Select Case cv Case 7 strSQL select * from evcp where pileno like cb1.TextAnd cardno like tb1.TextAnd operno like tb2.Text Case 6 strSQL select * from evcp where pileno like cb1.TextAnd cardno like tb1.Text Case 5 strSQL select * from evcp where pileno like cb1.TextAnd operno like tb2.Text Case 4 strSQL select * from evcp where pileno like cb1.Text Case 3 strSQL select * from evcp where cardno like tb1.TextAnd operno like tb2.Text Case 2 strSQL select * from evcp where cardno like tb1.Text Case 1 strSQL select * from evcp where operno like tb2.Text Case Else strSQL select * from evcp End SelectobjCommand.CommandText strSQLSet objRecordset objCommand.ExecuteDim i i0If (objRecordset.Bof And objRecordset.Eof) Then MsgBox(没有符合要求的记录) Else While Not objRecordset.EOF ii1 MSFlexGrid1.TextMatrix(i, 1) CStr(objRecordset.Fields(0).Value) MSFlexGrid1.TextMatrix(i, 2) CStr(objRecordset.Fields(1).Value) MSFlexGrid1.TextMatrix(i, 3) CStr(objRecordset.Fields(2).Value) MSFlexGrid1.TextMatrix(i, 4) CStr(objRecordset.Fields(3).Value) MSFlexGrid1.TextMatrix(i, 5) CStr(objRecordset.Fields(4).Value) MSFlexGrid1.TextMatrix(i, 6) CStr(objRecordset.Fields(5).Value) MSFlexGrid1.TextMatrix(i, 7) CStr(objRecordset.Fields(6).Value) MSFlexGrid1.TextMatrix(i, 8) CStr(objRecordset.Fields(7).Value) MSFlexGrid1.TextMatrix(i, 9) CStr(objRecordset.Fields(8).Value) MSFlexGrid1.TextMatrix(i, 10) CStr(objRecordset.Fields(9).Value) objRecordset.movenext Wend End IfSet objCommand Nothing objConnection.Close Set objRecordset Nothing Set objConnection NothingEnd Sub 欢迎关注
http://www.yutouwan.com/news/382436/

相关文章:

  • 怎么做好网站建设秀网站模板
  • 南京网站建设网站设计云南建设工程招标网站
  • dw自己做网站需要什么区别网络推广的概念
  • 电子商务网站规划与建设论文做美食推广的网站
  • 培训网站app网站建设济宁
  • 制作网站的专业公司网页设计外包价格
  • 大型网站开发什么书籍好自己搭建的网站可以收费吗
  • 个人网站设计开题报告邯郸最新消息
  • php一个企业网站多钱酒店网站搜索引擎优化方案
  • 织梦网站模板安装教程优质公司网站
  • 网站外链工具小程序与app有什么区别
  • 网站 平均加载时间建设公司起名
  • 南宁在哪里推广网站如何做网站的版块规划
  • 做h5商城网站本地网站制作
  • 创建网站的过程设计本笔记本推荐
  • 文化馆建设网站网站首页框架图
  • 哈尔滨市做淘宝的网站泰州市建设局网站
  • 香河做网站shijuewang应用商店oppo版本下载
  • 做企业平台的网站有哪些方面沈阳网站建设024idc
  • 天津做网站的公司有哪家丰都网站建设案例
  • 网站建设普及型个人网页设计图片素材网
  • 企业网站的首页网站备案收费吗
  • 港巢网站建设广西建设网证件查询电子证打印
  • 千博企业网站管理系统营销旗舰版广州冼村为什么叫土豪村
  • 重庆微信企业网站网站建设特效大全
  • 丹东网站设计html网址怎么打开
  • 做交易网站需要多少钱可以做外链的网站
  • 如何进外贸大公司网站在网站做推广要钱吗
  • 白云高端网站建设案例新图闻的合作伙伴
  • 做网站没有活怎么做二十八页美食网站