'?'附近的语法无效错误

时间:2015-09-07 15:56:17

标签: vb.net

我已将数据库从MS Access转换为SQL Server。因此,在保存图像时会抛出此错误。我该如何解决这个问题?

这是我的代码:

SelStr = "" &
          "Update Admission Set AdmissionNo = '" & AdmNo & "', ENClass = '" & Enclass & "', StudentFN = '" & SFN & "', " &
          "StudentMN = '" & SMN & "', StudentLN = '" & SLN & "', FatherFN = '" & FFN & "', FatherMN = '" & FMN & "', " &
          "FatherLN = '" & FLN & "', MotherFN = '" & MFN & "', MotherMN = '" & MMN & "', MotherLN = '" & MLN & "', " &
          "GuardianFN = '" & GFN & "', GuardianLN = '" & GLN & "', GRelation = '" & GRel & "', CCity = '" & CCity & "', " &
          "FatMob = '" & FathMo & "', AltNo = '" & AltNo & "', Gender =  '" & Gender & "', Category = '" & Category & "', " &
          "Religion = '" & Religion & "', PSName = '" & PSName & "', PSClass = '" & PSClass & "', PSGrade = '" & PSGrade & "', " &
          "PSCity = '" & PSCity & "', PSState = '" & PSState & "', PSPYear = '" & PSYear & "', AddressPer = '" & AddPer & "', " &
          "AddressPre = '" & AddPre & "', Remark = '" & Remark & "', DOB = '" & DOB & "', JnDt = '" & JnDt & "', " &
          "FOcc = '" & Focc & "', FEdu = '" & FEdu & "', FASal = '" & FASal & "', MOcc ='" & MOcc & "', MEdu = '" & MEdu & "', " &
          "MASal = '" & MASal & "', BusFacility = '" & BusFac & "', BusFrmID=0 , BusFrm = 'NA', " &
          "BroSis = '" & BroSis & "', Attachments = '" & AttachLis & "', AttachmentIDs = '" & AttIDs & "', MotMob = '" & MothMo & "', " &
          "[Cast] = '" & SCast & "', SMSNo = '" & SMSNo & "',Student_Images=" & strImage & ",SType = '" & SType & "',Email = '" & Email & "',Aadhar = '" & Aadhar & "' Where AdmissionID = " & temp & ""

    cmd.CommandText = SelStr

    If strImage = "?" Then
        cmd.Parameters.Add(strImage, SqlDbType.Image).Value = arrImage
    End If

    cmd.ExecuteNonQuery()

1 个答案:

答案 0 :(得分:0)

If strImage = "?" Then
        cmd.Parameters.Add(strImage,

您不应使用'?'

的参数名称

(我同意佐哈尔)。