vb中mshflexgrid为什么增加数据总是出问题
为什么我文本框中输入0.8,mshflexgrid显示的不是0.8?支管阻力平衡率的字段类型是单精度型,我想改小数位数,在access里每次改完关闭再打开又恢复原样?而且我只有录入数据的时候输入该字段的值才能运行,否则总是报错“insert语句语法错误”
程序代码:
Private Sub Command10_Click() Call K(conn) '连接数据库 '输入数据 Dim sql As String sql = "insert into [设计计算] ( [管段编号],[设计风量(m3/h)],[管长(m)],[比摩阻],[局部阻力系数],[管径(mm)],[实际风速(m/s)],[沿程阻力(Pa)],[局部阻力(Pa)],[总阻力(Pa)],[实际风量(m3/h)],[风量偏差率(%)],[支管阻力平衡率(%)]) values ( '" & Text4.Text & " ',' " & Text3.Text & " ', ' " & Text5.Text & " ', ' " & Text6.Text & " ' , ' " & Text7.Text & " ', ' " & Text10.Text & " ', ' " & Text9.Text & " ', ' " & Text11.Text & " ', ' " & Text12.Text & " ', ' " & Text13.Text & " ',' " & Text14.Text & " ', ' " & Text15.Text & " ', " & Text16.Text & " )" Set rs = New ADODB.Recordset '创建数据集对象的连接 rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic sql = "select * from [设计计算]" rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic Set MSHFlexGrid1.DataSource = rs Call title conn.Close '关闭连接 Set conn = Nothing '释放变量 End Sub