0

关于更新 sql db (Lover.db) 中的记录,我一直使用 basic4android。这有效:

 SQLLover.ExecNonQuery("UPDATE Profiles SET Mobile ='Nos', " & _
   "Name = 'Nme', Sunday = 'SundayX', Monday = 'MondayX', " & _
   "Tuesday = 'TuesdayX', Wednesday = 'WednesdayX', Thursday = 'ThursdayX', " & _
   " Friday = 'FridayX', Saturday = 'SaturdayX', " & _
   "StartTime = 'lblTimeFrom.text', EndTime = 'lblTimeTo.Text' " & _
   "WHERE Mobile='07xxxxxxxxx' AND Name='Sam'")

但当然只是用单引号中的数据更新。我想使用一些变量,并尝试过这个;

SQLLover.ExecNonQuery2("Update Profiles SET(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", & _
    Array As Object(Nos, Nme, SundayX, MondayX, TuesdayX, WednesdayX, & _
    ThursdayX, FridayX, SaturdayX, lblTimeFrom.Text, lblTimeTo.Text))

这是正确的语法吗?当然,, Nos,NmeSundayX是我的变量。

4

2 回答 2

0

你的UPDATE语法完全错误。正确的语法是UPDATE table SET column = value, column2 = value2等等。您的代码甚至没有做任何与您的代码相近的事情。我不会费心把整件事都打出来,但我会做的足够让你开始:

SQLLover.ExecNonQuery2("Update Profiles " & _
  "SET Mobile = ?, Name = ?, Sunday = ?, Monday = ?", & _
  Array As Object(Nos, Nme, SundayX, MondayX))
于 2013-01-19T17:09:18.003 回答
0

使用您的代码,即工作代码,为了能够在查询中使用变量,您必须转义查询并连接变量。看看这个简短的例子

SQLLover.ExecNonQuery("UPDATE Profiles SET Mobile = ' " & NOs & " ', Name = ' "&NMe & " ' WHERE Name = ' " & OldNameVariable & " ' ")

SO TO USE VARIABLE 插入 “& VARIABLENAME &” ,如示例(Mobile = '“& Nos &”')

提示:最后一个查询应如下所示: AND Name=' " & SamOldVariableName & " ' " )

于 2016-02-12T15:18:53.517 回答