您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



有哪位用vb做过测温系统,关于温度的保存


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


有哪位用vb做过测温系统,关于温度的保存
发表于:2007-03-08 17:36:09 楼主
按照国标:每个温度值占两个字节(二进制数),数值为实际温度的10倍,即温度精确到0.1;
在access数据库中用二进制ole类型存放,怎么放进去啊?以及取出来后如何解析?
现在我用java解析一个测温软件(vb做的)的access数据库,怎么都解析不出来了。
发表于:2007-03-08 17:47:131楼 得分:0

import   java.io.*;import   java.sql.*;import   java.util.*;import   javax.servlet.*;import   javax.servlet.http.*;   public   class   oleextraction   {           public   static   void   main(string[]   args)   {                         try   {                                 class.forname( "sun.jdbc.odbc.jdbcodbcdriver ");                                 //   set   this   to   a   ms   access   db   you   have   on   your   machine                                 string   filename   =   "c:/pictures.mdb ";                                 string   database   =   "jdbc:odbc:driver={microsoft   access   driver   (*.mdb)};dbq= ";                                 database+=   filename.trim()   +   ";driverid=22;readonly=true} ";   //   add   on   to   the   end                                   //   now   we   can   get   the   connection   from   the   drivermanager                                 connection   con   =   drivermanager.getconnection(   database   , " ", " ");                                   statement   s   =   con.createstatement();                                 s.EXECute( "select   employeeid,   picture   from   iddata   where   employeeid   =   '00526 ' ");                                 stringbuffer   results   =   new   stringbuffer();                                 resultset   rs   =   s.getresultset();                                   if     (rs   !=   null   )   {                                         while   (   rs.next()   )   {                                                         inputstream   image   =   rs.getbinarystream(2);                                                         fileoutputstream   file   =   null;                                                         file   =   new   fileoutputstream   ( "c:/picture.jpg ");                                                         int   chunk;                                                         while   ((chunk   =   image.read())   !=   -1)                                                         file.write(chunk);                                         }                                 }                                 s.close();                         }                           catch   (exception   e)   {                                 system.out.println( "error:   "   +   e);                         }         }}

发表于:2007-03-08 18:36:252楼 得分:0
谢谢楼上的。可是那不是我需要的结果。我想知道怎么能够把数解析出来;
二进制里面保存的是数字,我现在想把这些数字解析出来。本来是312个数字存放的,但是现在我解析出来的长度是624,刚好两倍。
.....................
byte[]   bt   =   rst.getbytes( "temperatureset ");
system.out.println( "----总长度: "   +   bt.length);
for(int   i=0;i <bt.length;i=i+1){
        system.out.println( "---- "   +   i   +   "--------- "   );
        system.out.println( "10进制: "   +   (char)bt[i]);
        system.out.println( "acii: "   +   bt[i]);
        system.out.println( "16进制: "   +   integer.tohexstring(bt[i]));
        system.out.println( "2进制: "   +   integer.tobinarystring(bt[i]));
}
..........

打印出来的结果是:
----总长度:624
----0---------
10进制:
acii:15
16进制:f
2进制:1111
----1---------
10进制:
acii:18
16进制:12
2进制:10010
发表于:2007-03-08 19:08:203楼 得分:0
温度数值可储存于整型字段,其数值范围为-32768到32767,按你的考虑就是-3276.8到3276.7。不必要储存于备注类型字段。那么取出字段值除以10就是你要的数值。
发表于:2007-03-09 18:51:404楼 得分:0
温度值可能为小数的。所以需要转化为整数存放。必须按照那个国标保存。取出来后肯定得解析除10的。
发表于:2007-03-12 17:11:155楼 得分:0
呵呵。我已经基本搞出来了:((float)bt[i]+bt[++i])/10;就可以了。还是谢谢大家的支持。
发表于:2007-03-13 09:55:366楼 得分:0
该回复于2007-12-28 18:06:23被管理员或版主删除


快速检索

最新资讯
热门点击