我在写INSERT语句时不知道怎样使用符号&和单引号'   ?
现在有4个变量值(id,nm,tp,iw),我想通过insret into 语句写进数据库的表中:txtSQL = "INSERT INTO TInstrument (InstrumentID,InstrumentName,InstrumentType,MinWaveLength,MaxWavelength,Distiguishing,Angle,Manufactory,YieldDate,MarkDate,MarkUnit,Memo) VALUES (................)"
请问省略号部分该怎么写?
  

解决方案 »

  1.   

    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES (................)"
    请问省略号部分该怎么写?
      

  2.   

    id="'"+id+"'"
    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES (id)
    其他一样
      

  3.   

    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES (" & id & ",'" & nm & "','" & tp & "'," & tw & " )"
      

  4.   

    id,nm,tp,iw
    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES ("'"+id+"'","'"+nm+"'","'"+tp+"'"+"'"+iw+"'")
    就行了
      

  5.   

    如果这四个字段是数值型用下面的方法
    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES (" & id & "," & nm & "," & tp & "," & iw & " )"
    如果是字符型可以用下面的
    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES ('" & id & "','" & nm & "','" & tp & "','" & iw & "')"具体哪里要加“'”请查看资料。
      

  6.   

    txtSQL = "INSERT INTO TInstrument(InstrumentID,InstrumentName,InstrumentType,MinWaveLength) VALUES ("'"+id+"'","'"+nm+"'","'"+tp+"'","'"+iw+"'")
    就行了