回 帖 发 新 帖 刷新版面

主题:类型不匹配如何破

 Dim dte As Date
   Dim area As Integer
   Dim loc As Long
   Dim dep As String
   Dim dev As String
   Dim name As String
   Dim ip As String
  area = CInt(Trim(Combo1.Text))
  loc = CLng(Trim(Combo2.Text))
  dep = Chr(Trim(Combo3.Text))
  dev = Chr(Trim(Combo4.Text))
  name = Chr(Trim(Text1.Text))
  ip = Chr(Trim(Combo5.Text))
   dte = DateValue(Format(Now, "yyyy.mm.dd"))
   Set DB = New ADODB.Connection
   Set rs = New ADODB.Recordset
   DB.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=report/report;Extended Properties=DRIVER={Microsoft ODBC for Oracle};UID=report/report;SERVER=lzerp;"
   DB.Open
   rs.CursorLocation = adUseClient
  
   rs.Open "update ip_address set area_no=" & area & ",location=" & loc & ",dept='" & dep & "',device_name='" & dev & "',name='" & name & "',create_date='" & dte & "',flag=1 where ip='" & ip & "' and flag=0", DB, 1, 4

    MsgBox "!", vbOKOnly, ""

这段在有些电脑上执行报错提示类型不匹配,有些电脑上执行没问题,哪位高手给指导一下

0

回复列表 (共1个回复)

沙发

你对chr函数的理解不对

chr(48)的结果是个字母,参数应该是一个0~255的正整数

text本身是字符串,trim只是去掉前后的无用空格

把它作为chr的参数,肯定类型就不配了

我来回复

您尚未登录,请登录后再回复。点此登录或注册